I need help creating variables based on the year and month for a set of longitudinal data where the first year of data for each person is '1' and monthly variables are created : Var1_1 - Var1_12 This needs to be done for all subsequent years until all the data for each person is exhausted. And the observation falls in e.g. 1_1 then it equals the var data, but if there is no data for that year/month, then value equals zero. Below is a sample of what my data looks like ID Year Month Var Var1_1 ID-1 2000 1 XX XX ID-1 2000 4 XX 0 ID-1 2002 6 XX 0 ID-2 1990 1 XX XX ID-2 2000 1 XX 0 ID-3 1999 2 XX 0 So for example the third line would only have corresponding data in Var3_6 -- since 2002 is the third year for ID-1 Any help would be greatly appreciated. I've been trying to do a loop for each person, but nothing is working out .
... View more