My data looks like this
id | ts1 | ts2 | ts3 | … | ts65 | tact1 | tact2 | tact3 | …. | tact65 |
1 | 1 | 4 | 5 | 75 | 111 | 121 | 234 | 111 | ||
2 | 1 | 3 | 6 | 80 | 111 | 131 | 313 | 111 | ||
3 | 1 | 4 | 5 | 90 | 111 | 141 | 123 | 111 |
tact* is the activity that was performed on that slot.
I need to make variables called act* based on the value of time slots and tact.
I need to make activity variables corresponds to the time slot.
For instance, this is what I need to make from the above dataset:
id | act1 | act2 | act3 | act4 | act5 | act6 | … | act144 |
1 | 111 | 111 | 111 | 121 | 234 | 234 | ||
2 | 111 | 111 | 131 | 131 | 131 | 313 | ||
3 | 111 | 111 | 111 | 141 | 123 | 123 |
I tried forvalues, but wasn't able to figure it out how to create proper loop.
I don't even know how to explain this in sentence - I am sorry if my explanation doesn't make much sense.
I would appreciate any help you could give..Thank you so much.
0 Response to making a number of variables based on values of other variables
Post a Comment