I am having a problem and looking forward to your help. You can see one part of my data set as below. I am using nested logit model and need to classify 50 altenatives(province_name) into 6 nests (Red River Delta, North Midlands, North Centrals, Central Higlands, South East, Mekong River) by creating a new variable "type".
In order to do this, my code is:
nlogitgen type=province_name (Red River Delta: Vinhphuc province|Quangninh province|Hungyen prvince|Haiduong province|Hanam province|Haiphong city|Ninhbinh province|Hanoi city|Bacninh province|Namdinh province|Thaibinh province, North Midlands: Phutho province| Thainguyen province|Bacgiang province|Backan province|Yenbai province|Langson province|Hoabinh province, North Centrals: Quangnam province|Quangngai province|Thanhhoa province|Phuyen province|Danang city|Nghean province |Khanhhoa province|Binhthuan province|Hatinh province|Quangbinh province|Quangtri province|Thuathienhue province|Binhdinh province, Central Highlands: Lamdong province, South East: Binhphuoc province|Dongnai province|Tayninh province|Hochiminh city|Binhduong province| Ba Ria -Vung Tau, Mekong River: Bentre province|Dongthap province|Longan province|Vinhlong province|Tiengiang province|Travinh province|Angiang province|Kiengiang province|Cantho city|Haugiang province|Soctrang province|Baclieu province)
I follow the example in page 8-11 of this link: cmnlogit.pdf (stata.com)
However, I got the error: no observations for province_name == Vinhphuc
r(198);
Here is my data sample.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str10 tax_code str2 province_code float province_chosen str22 province_name "0101744855" "31" 0 "Haiphong city" "0101744855" "27" 0 "Bacninh province" "0101744855" "30" 0 "haiduong province" "0101744855" "22" 0 "Quangninh province" "0101744855" "34" 0 "Thaibinh province" "0101744855" "54" 0 "Phuyen province" "0101744855" "26" 0 "Vinhphuc province" "0101744855" "01" 1 "Hanoi city" "0101744855" "86" 0 "Vinhlong province" "0101744855" "35" 0 "Hanam province" "0101744855" "19" 0 "Thainguyen province" "0101744855" "37" 0 "Ninhbinh province" "0101744855" "80" 0 "Longan province" "0101744855" "87" 0 "Dongthap province" "0101744855" "24" 0 "Bacgiang province" "0101744855" "83" 0 "Bentre province" "0101744855" "72" 0 "Tayninh province" "0101744855" "82" 0 "Tiengiang province" "0101744855" "06" 0 "Backan province" "0101744855" "68" 0 "Lamdong province" "0101744855" "36" 0 "namdinh province" "0101744855" "77" 0 "Baria-vungtau province" "0101744855" "74" 0 "Binhduong province" "0101744855" "49" 0 "Quangnam province" "0101744855" "79" 0 "Hochiminh city" "0101744855" "33" 0 "Hungyen prvince" "0101744855" "48" 0 "Danang city" "0101744855" "40" 0 "Nghean province" "0101744855" "25" 0 "Phutho province" "0101744855" "51" 0 "Quangngai province" "0101744855" "38" 0 "Thanhhoa province" "0101744855" "75" 0 "Dongnai province" "0101744855" "70" 0 "Binhphuoc province" "0107952393" "40" 0 "Nghean province" "0107952393" "37" 0 "Ninhbinh province" "0107952393" "31" 0 "Haiphong city" "0107952393" "22" 0 "Quangninh province" "0107952393" "83" 0 "Bentre province" "0107952393" "01" 1 "Hanoi city" "0107952393" "30" 0 "haiduong province" "0107952393" "19" 0 "Thainguyen province" "0107952393" "36" 0 "namdinh province" "0107952393" "48" 0 "Danang city" "0107952393" "68" 0 "Lamdong province" "0107952393" "75" 0 "Dongnai province" "0107952393" "70" 0 "Binhphuoc province" "0107952393" "35" 0 "Hanam province" "0107952393" "86" 0 "Vinhlong province" "0107952393" "27" 0 "Bacninh province" "0107952393" "51" 0 "Quangngai province" "0107952393" "79" 0 "Hochiminh city" "0107952393" "87" 0 "Dongthap province" "0107952393" "33" 0 "Hungyen prvince" "0107952393" "80" 0 "Longan province" "0107952393" "38" 0 "Thanhhoa province" "0107952393" "25" 0 "Phutho province" "0107952393" "26" 0 "Vinhphuc province" "0107952393" "82" 0 "Tiengiang province" "0107952393" "06" 0 "Backan province" "0107952393" "49" 0 "Quangnam province" "0107952393" "54" 0 "Phuyen province" "0107952393" "24" 0 "Bacgiang province" "0107952393" "77" 0 "Baria-vungtau province" "0107952393" "74" 0 "Binhduong province" "0107952393" "72" 0 "Tayninh province" "0107952393" "34" 0 "Thaibinh province" "0107997813" "72" 0 "Tayninh province" "0107997813" "49" 0 "Quangnam province" "0107997813" "54" 0 "Phuyen province" "0107997813" "86" 0 "Vinhlong province" "0107997813" "24" 0 "Bacgiang province" "0107997813" "31" 0 "Haiphong city" "0107997813" "38" 0 "Thanhhoa province" "0107997813" "30" 0 "haiduong province" "0107997813" "34" 0 "Thaibinh province" "0107997813" "68" 0 "Lamdong province" "0107997813" "27" 0 "Bacninh province" "0107997813" "83" 0 "Bentre province" "0107997813" "37" 0 "Ninhbinh province" "0107997813" "06" 0 "Backan province" "0107997813" "75" 0 "Dongnai province" "0107997813" "74" 0 "Binhduong province" "0107997813" "01" 1 "Hanoi city" "0107997813" "22" 0 "Quangninh province" "0107997813" "19" 0 "Thainguyen province" "0107997813" "36" 0 "namdinh province" "0107997813" "25" 0 "Phutho province" "0107997813" "70" 0 "Binhphuoc province" "0107997813" "33" 0 "Hungyen prvince" "0107997813" "82" 0 "Tiengiang province" "0107997813" "40" 0 "Nghean province" "0107997813" "51" 0 "Quangngai province" "0107997813" "48" 0 "Danang city" "0107997813" "80" 0 "Longan province" "0107997813" "26" 0 "Vinhphuc province" "0107997813" "77" 0 "Baria-vungtau province" "0107997813" "35" 0 "Hanam province" "0107997813" "87" 0 "Dongthap province" "0107997813" "79" 0 "Hochiminh city" "0108058196" "70" 0 "Binhphuoc province" end
nlogitgen type=province(Red River Delta: Vinhphuc province|Quangninh province|Hungyen prvince|Haiduong province|Hanam province|Haiphong city|Ninhbinh province|Hanoi city|Bacninh province|Namdinh province|Thaibinh province, North Midlands: Phutho province| Thainguyen province|Bacgiang province|Backan province|Yenbai province|Langson province|Hoabinh province, North Centrals: Quangnam province|Quangngai province|Thanhhoa province|Phuyen province|Danang city|Nghean province |Khanhhoa province|Binhthuan province|Hatinh province|Quangbinh province|Quangtri province|Thuathienhue province|Binhdinh province, Central Highlands: Lamdong province, South East: Binhphuoc province|Dongnai province|Tayninh province|Hochiminh city|Binhduong province| Ba Ria -Vung Tau, Mekong River: Bentre province|Dongthap province|Longan province|Vinhlong province|Tiengiang province|Travinh province|Angiang province|Kiengiang province|Cantho city|Haugiang province|Soctrang province|Baclieu province)
but still get the error
(value label dereference "Vinhphuc":province not found)
no observations for province == Vinhphuc
r(198);
I really look forward to your help.
Thanks a lot.
Sophie.
0 Response to No observation error when creating new variables
Post a Comment