Hello.
I wish to create a dataset in which each observation is one specific category of a categorical variable. Now, I'm aware Stata does not make any difference between categorical and continuous variables. However, in my specific case, I define a continuous variable as any variable that has more than 10 categories. If a variable is continuous, then I wish to have only one observation for this. With a toy example, this is the original dataset:
And this is what I wish to achieve:
Any help would be appreciated!
I wish to create a dataset in which each observation is one specific category of a categorical variable. Now, I'm aware Stata does not make any difference between categorical and continuous variables. However, in my specific case, I define a continuous variable as any variable that has more than 10 categories. If a variable is continuous, then I wish to have only one observation for this. With a toy example, this is the original dataset:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input int(candidat inc) float frac double(pfrac pop) 3 1 23 3.22 49878 4 1 18 2.5200000000000005 39035 2 1 59 8.260000000000002 127947 2 2 45 10.799999999999999 167292 3 2 35 8.4 130116 4 2 20 4.8 74352 4 3 21 6.3 97587 2 3 41 12.299999999999999 190527 3 3 38 11.4 176586 2 4 40 8 123920 3 4 42 8.4 130116 4 4 18 3.6 55764 4 5 16 2.08 32219 2 5 36 4.68 72493 3 5 48 6.24 96658 end label values candidat candidat label def candidat 2 "Clinton", modify label def candidat 3 "Bush", modify label def candidat 4 "Perot", modify label values inc inc2 label def inc2 1 "<$15k", modify label def inc2 2 "$15-30k", modify label def inc2 3 "$30-50k", modify label def inc2 4 "$50-75k", modify label def inc2 5 "$75k+", modify
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str10 variable "candidat_2" "candidat_3" "candidat_4" "inc_1" "inc_2" "inc_3" "inc_4" "inc_5" "frac" "pfrac" "pop" end
Comment