I have a data with these sequential variable names.
p1_1_1_1 | p1_1_1_2 | p1_1_1_3 | p1_1_1_4 | p1_1_2_1 | p1_1_2_2 | p1_1_2_3 | p1_1_2_4 | p1_1_3_1 | p1_1_3_2 | p1_1_3_3 | p1_1_3_4 |
1 | 1 | 1 | 1 | 2 | 2 | 2 | 2 | 3 | 3 | 3 | 3 |
1 | 1 | 1 | 1 | 2 | 2 | 2 | 2 | 3 | 3 | 3 | 3 |
1 | 1 | 1 | 1 | 2 | 2 | 2 | 2 | 3 | 3 | 3 | 3 |
I would like to sum the sequential variable names as follows:
generate p1_1_1 = p1_1_1_1 + p1_1_1_2 + p1_1_1_3 + p1_1_1_4
generate p1_1_2 = p1_1_2_1 + p1_1_2_2 + p1_1_2_3 + p1_1_2_4
...
Somebody can help me for doing the same using loops...
Thanks a lot...
0 Response to Generate sum of variables with sequential variables names
Post a Comment