My data is from a survey where members of a household were entered into blocks of variables. For example, if someone meets X criteria they are entered into the variables 1-3, starting with variable 1; if someone meets Y criteria then they are entered into the variables 4-6, starting with variable 4; if someone meets Z criteria they are entered into variables 7-9, starting with variable 7. I am now tasked with creating one set of variables to hold all the information, but I am not sure how to restructure the data. Example of current data structure: Fname_1 Lname_1 Age_1 Gender_1 Fname_2 Lname_2 Age_2 Gender_2 Fname_3 Lname_3 Age_3 Gender_3 Fname_4 Lname_4 Age_4 Gender_4 Fname_5 Lname_5 Age_5 Gender_5 Fname_6 Lname_6 Age_6 Gender_6 Fname_7 Lname_7 Age_7 Gender_7 Fname_8 Lname_8 Age_8 Gender_8 Fname_9 Lname_9 Age_9 Gender_9 Kate Black 20 F . . . . . . . . Louis White 35 M Kitty White 36 F . . . . . . . . . . . . . . . . Lucy Red 18 F Tom Red 17 . . . . . . . . . . . . . . . . . Paul Red 76 M Sarah Red 77 F . . . . . . . . . . . . . . . . Patricia Yellow 60 F Frank Yellow 62 M . . . . Kate Yellow 11 F . . . . . . . . Jeff Blue 15 M . . . . . . . . . . . . . . . . . . . . Lillian Blue 25 F . . . . . . . . This leaves a lot of missing data. I want to be able to make one household roster, removing the missing data. So that it looks like this: Fname_1 Lname_1 Age_1 Gender_1 Fname_2 Lname_2 Age_2 Gender_2 Fname_3 Lname_3 Age_3 Gender_3 Fname_4 Lname_4 Age_4 Gender_4 Fname_5 Lname_5 Age_5 Gender_5 Fname_6 Lname_6 Age_6 Gender_6 Fname_7 Lname_7 Age_7 Gender_7 Fname_8 Lname_8 Age_8 Gender_8 Fname_9 Lname_9 Age_9 Gender_9 Kate Black 20 F Louis White 35 M Kitty White 36 F . . . . . . . . . . . . . . . . . . . . . . . . Lucy Red 18 F Tom Red 17 Paul Red 76 M Sarah Red 77 F . . . . . . . . . . . . . . . . . . . . . Patricia Yellow 60 F Frank Yellow 62 M Kate Yellow 11 F . . . . . . . . . . . . . . . . . . . . . . . . Jeff Blue 15 M Lillian Blue 25 F . . . . . . . . . . . . . . . . . . . . . . . . . . . . My question is: how do I pull out the data that exists and put it into variables as per my example. I am familiar with arrays and do-loops, and have tried some manipulations with these, without success. Any guidance, advice, or suggestions are much appreciated! Thank you!
... View more