Hi! I am trying to create seven summary variables named den_1 to den_7 to simplify the results I have from 34 variables named total1-total34. Although there are 34 different groups, each observation actually only belongs to 7 groups at most. The number of groups that each belongs is shown by the variable group_n.
Enquiry:
Is possible that the -foreach- command or -forvalue- command can search over the 34 variables, take out the values, and put it in a new sets of variables (den_1- den_7)?
Data example skipping variables for simplification:
Thank you all very much!!
Enquiry:
Is possible that the -foreach- command or -forvalue- command can search over the 34 variables, take out the values, and put it in a new sets of variables (den_1- den_7)?
Data example skipping variables for simplification:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(total1 total2 total3 total32 total33 total34 group_n) 208 207 . . . . 4 208 207 . . . . 4 . . . . . . 0 . . . . . . 1 208 207 . . . . 4 . . . . . . 1 . . . . . . 4 . . . . . . 0 . . . . . . 2 . . . . . . 1 . . . . . . 0 . . . . . . 2 . . . . . . 0 . . . . . . 1 . . . . . . 0 208 207 . . . . 4 . . . . . . 2 . . . . . . 3 . . . . . . 0 . . . . . . 0 . . . . . . 2 . . . . . . 0 . . . . . . 0 . . . . 5 . 2 208 207 . . . . 5 . . . . . . 0 . . . . . . 3 . . . . . . 0 . . . . . . 0 . . . . . . 2 . . . . . . 2 . . . . . . 0 . . . . . . 0 . . . . . . 2 . . . . . . 0 208 207 50 . . . 5 . . . . . . 1 . . . . . . 3 . . . . . . 0 . . . . . . 0 . . . . . . 0 . . . . . . 0 208 207 . . . . 5 . . . . . . 2 . . . . . . 2 . . . . . . 1 . . . . . . 1 . . . . . . 2 208 207 . . . . 5 . . . . . . 0 . . . . . . 0 . . . . . . 1 . . . . . . 0 . . . . . . 0 . . . . . . 3 . . . . . . 2 . . . . . . 0 . . . . . . 2 . . . . . . 0 208 207 . . . . 5 . . . . . . 0 . . . . . . 0 . . . . . . 1 . . . . . . 2 208 207 . . . . 6 . . . . . . 4 . . . . . . 2 208 207 . . . . 6 . . . . . . 2 . . . . . . 2 . . . . . . 3 208 207 . . . . 5 . . . . . . 3 . . 50 . . . 2 . . . . . . 0 . . . . . . 2 . . . . . . 0 . . . . . . 3 . . . . . . 0 . . . . . . 0 . . . . . . 0 . . 50 . . . 2 . . 50 . . . 3 . . . . . . 0 . . . . . . 3 . . . . . . 0 . . . . . . 0 208 207 . . . . 5 . . . . . . 0 . . . . . . 0 . . . . . . 2 208 207 . . . . 4 . . . 5 . . 3 . . . . . . 2 . . . . . . 3 . . . . . . 2 . . . . . . 5 . . . . . . 0 . . . . . . 0 . . . . . . 0 end
Comment