[input str6 hhold double(S9EQ00 S9EQ01)
"1006" 1016 1
"1006" 1017 2
"1006" 1018 2
"1006" 1026 2
"1006" 1027 1
"1006" 1028 2
"1006" 1029 2
"1006" 1031 1
"1006" 1032 2
"1006" 1033 1
"1006" 1034 2
"1006" 1043 2
"1009" 1016 1
"1009" 1017 2
"1009" 1018 2
"1009" 1026 2
"1009" 1027 1
"1009" 1028 2
"1009" 1029 2
"1009" 1031 2
"1009" 1032 2
"1009" 1033 2
"1009" 1034 2
"1009" 1043 1
"1014" 1016 1
"1014" 1017 2
"1014" 1018 2
"1014" 1026 2
"1014" 1027 2
"1014" 1028 2
"1014" 1029 2
"1014" 1031 2
"1014" 1032 2
"1014" 1033 2
"1014" 1034 2
"1014" 1043 2
"1028" 1016 2
"1028" 1017 2
"1028" 1018 2
"1028" 1026 2
"1028" 1027 2
"1028" 1028 2
"1028" 1029 2
"1028" 1031 2
"1028" 1032 2
"1028" 1033 2
"1028" 1034 2
"1028" 1043 2
"1029" 1016 2
"1029" 1017 2
"1029" 1018 2
"1029" 1026 2
"1029" 1027 2
"1029" 1028 2
"1029" 1029 2
"1029" 1031 2
"1029" 1032 2
"1029" 1033 2
"1029" 1034 2
"1029" 1043 2
"1033" 1016 1
"1033" 1017 2
"1033" 1018 2
"1033" 1026 2
"1033" 1027 1
"1033" 1028 2
"1033" 1029 2
"1033" 1031 2
"1033" 1032 2
"1033" 1033 2
"1033" 1034 2
"1033" 1043 2
"1038" 1016 1
"1038" 1017 2
"1038" 1018 2
"1038" 1026 2
"1038" 1027 1
"1038" 1028 2
"1038" 1029 2
"1038" 1031 2
"1038" 1032 2
"1038" 1033 2
"1038" 1034 2
"1038" 1043 2
"1045" 1016 2
"1045" 1017 2
"1045" 1018 2
"1045" 1026 2
"1045" 1027 1
"1045" 1028 2
"1045" 1029 2
"1045" 1031 2
"1045" 1032 2
"1045" 1033 2
"1045" 1034 2
"1045" 1043 2
"1048" 1016 1
"1048" 1017 2
"1048" 1018 2
"1048" 1026 2
end
label values S9EQ00 S9EQ00
label def S9EQ00 1016 "TV set", modify
label def S9EQ00 1017 "Desktop Computer", modify
label def S9EQ00 1018 "Laptop Computer", modify
label def S9EQ00 1026 "Microwave/ Electric Oven", modify
label def S9EQ00 1027 "Refreigerator/Fridger", modify
label def S9EQ00 1028 "*Air Conditioner/ Cooler (AC)", modify
label def S9EQ00 1029 "Washing Machine", modify
label def S9EQ00 1031 "Bicycle", modify
label def S9EQ00 1032 "Rikshaw/Auto-Rikshaw/Easybike", modify
label def S9EQ00 1033 "Motorcycle/Scooter", modify
label def S9EQ00 1034 "Motor Car", modify
label def S9EQ00 1043 "Boat/Engine Boat", modify
label values S9EQ01 yesno
label def yesno 1 "Yes", modify
label def yesno 2 "No", modify
[/CODE]
][/CODE]
From the data hhold is the household ID, 1006 is household-1, 1009 is household-2 and so on. S9EQ00 the code of durable goods. S9EQ01 is whether the household own that specific durable good or not (1=yes and 2=no). I want to generate a count variable, varying from 1-12 (as I have 12 items). The variable will take a value of 1 if the household has only 1 durable good among 12. It will have a value of 4 if it has 4 durable goods. How can I generate it in STATA? Note: I cannot use the code rowsum as I am using STATA 14.
"1006" 1016 1
"1006" 1017 2
"1006" 1018 2
"1006" 1026 2
"1006" 1027 1
"1006" 1028 2
"1006" 1029 2
"1006" 1031 1
"1006" 1032 2
"1006" 1033 1
"1006" 1034 2
"1006" 1043 2
"1009" 1016 1
"1009" 1017 2
"1009" 1018 2
"1009" 1026 2
"1009" 1027 1
"1009" 1028 2
"1009" 1029 2
"1009" 1031 2
"1009" 1032 2
"1009" 1033 2
"1009" 1034 2
"1009" 1043 1
"1014" 1016 1
"1014" 1017 2
"1014" 1018 2
"1014" 1026 2
"1014" 1027 2
"1014" 1028 2
"1014" 1029 2
"1014" 1031 2
"1014" 1032 2
"1014" 1033 2
"1014" 1034 2
"1014" 1043 2
"1028" 1016 2
"1028" 1017 2
"1028" 1018 2
"1028" 1026 2
"1028" 1027 2
"1028" 1028 2
"1028" 1029 2
"1028" 1031 2
"1028" 1032 2
"1028" 1033 2
"1028" 1034 2
"1028" 1043 2
"1029" 1016 2
"1029" 1017 2
"1029" 1018 2
"1029" 1026 2
"1029" 1027 2
"1029" 1028 2
"1029" 1029 2
"1029" 1031 2
"1029" 1032 2
"1029" 1033 2
"1029" 1034 2
"1029" 1043 2
"1033" 1016 1
"1033" 1017 2
"1033" 1018 2
"1033" 1026 2
"1033" 1027 1
"1033" 1028 2
"1033" 1029 2
"1033" 1031 2
"1033" 1032 2
"1033" 1033 2
"1033" 1034 2
"1033" 1043 2
"1038" 1016 1
"1038" 1017 2
"1038" 1018 2
"1038" 1026 2
"1038" 1027 1
"1038" 1028 2
"1038" 1029 2
"1038" 1031 2
"1038" 1032 2
"1038" 1033 2
"1038" 1034 2
"1038" 1043 2
"1045" 1016 2
"1045" 1017 2
"1045" 1018 2
"1045" 1026 2
"1045" 1027 1
"1045" 1028 2
"1045" 1029 2
"1045" 1031 2
"1045" 1032 2
"1045" 1033 2
"1045" 1034 2
"1045" 1043 2
"1048" 1016 1
"1048" 1017 2
"1048" 1018 2
"1048" 1026 2
end
label values S9EQ00 S9EQ00
label def S9EQ00 1016 "TV set", modify
label def S9EQ00 1017 "Desktop Computer", modify
label def S9EQ00 1018 "Laptop Computer", modify
label def S9EQ00 1026 "Microwave/ Electric Oven", modify
label def S9EQ00 1027 "Refreigerator/Fridger", modify
label def S9EQ00 1028 "*Air Conditioner/ Cooler (AC)", modify
label def S9EQ00 1029 "Washing Machine", modify
label def S9EQ00 1031 "Bicycle", modify
label def S9EQ00 1032 "Rikshaw/Auto-Rikshaw/Easybike", modify
label def S9EQ00 1033 "Motorcycle/Scooter", modify
label def S9EQ00 1034 "Motor Car", modify
label def S9EQ00 1043 "Boat/Engine Boat", modify
label values S9EQ01 yesno
label def yesno 1 "Yes", modify
label def yesno 2 "No", modify
[/CODE]
][/CODE]
From the data hhold is the household ID, 1006 is household-1, 1009 is household-2 and so on. S9EQ00 the code of durable goods. S9EQ01 is whether the household own that specific durable good or not (1=yes and 2=no). I want to generate a count variable, varying from 1-12 (as I have 12 items). The variable will take a value of 1 if the household has only 1 durable good among 12. It will have a value of 4 if it has 4 durable goods. How can I generate it in STATA? Note: I cannot use the code rowsum as I am using STATA 14.
Comment