|
Hello SPSS users,
An item in the questionnaire can be categorized as multiple response item where the multiple responses are coded 1, 2, 3, 4, 5, and 6. That is, each respondent can have at most 6 answers in the item. The data (n=2000) were encoded in two columns where the first column is the respondent ID while the second column contains the responses separated by commas and some have space(s) after the comma. The dataset looks like below: ID response 1 1,5,6 2 2, 4, 5,6 3 5,6 4 3,5, 6 .. .. .. 2000 1,3,5,6 From that dataset, I want to create my own dataset with seven columns where the first column is the ID, the second to the seventh columns have 0 or 1 entries. That is the data above is converted like the dataset below: ID category1 category2 category3 category 4 category5 category6 1 1 0 0 0 1 1 2 0 1 0 1 1 1 3 0 0 0 0 1 1 4 0 0 1 0 1 1 .. .. .. 2000 0 0 1 0 1 1 I appreciate if somebody could provide me the syntax. Thank you. J. Talili ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
Hello, I think that the following syntax will work. Please change the
name of the file. GET DATA /TYPE = TXT /FILE = 'C:\Dokumente und Einstellungen\FSC\Desktop\Neu1.txt' /DELCASE = LINE /DELIMITERS = " ," /ARRANGEMENT = DELIMITED /FIRSTCASE = 1 /IMPORTCASE = ALL /VARIABLES = ID F1.0 v1 F1.0 V2 F1.0 V3 F1.0 V4 F1.0 V5 F1.0 V6 F1.0. exe. numeric category1. numeric category2. numeric category3. numeric category4. numeric category5. numeric category6. vector IN = v1 to v6. vector OUT = category1 to category6. loop #idx=1 to 6. + do if not(missing(in(#idx))). + comp OUT(IN(#idx))=1. + end if. end loop. exe. recode category1 to category6 (sysmis=0). exe. Carsten. 2008/5/25 Juanito Talili <[hidden email]>: > Hello SPSS users, > > An item in the questionnaire can be categorized as multiple response item where the multiple responses are coded 1, 2, 3, 4, 5, and 6. That is, each respondent can have at most 6 answers in the item. The data (n=2000) were encoded in two columns where the first column is the respondent ID while the second column contains the responses separated by commas and some have space(s) after the comma. The dataset looks like below: > > ID response > 1 1,5,6 > 2 2, 4, 5,6 > 3 5,6 > 4 3,5, 6 > .. > .. > .. > 2000 1,3,5,6 > > From that dataset, I want to create my own dataset with seven columns where the first column is the ID, the second to the seventh columns have 0 or 1 entries. That is the data above is converted like the dataset below: > > ID category1 category2 category3 category 4 category5 category6 > 1 1 0 0 0 1 1 > 2 0 1 0 1 1 1 > 3 0 0 0 0 1 1 > 4 0 0 1 0 1 1 > .. > .. > .. > 2000 0 0 1 0 1 1 > > I appreciate if somebody could provide me the syntax. > > Thank you. > J. Talili > > ===================== > To manage your subscription to SPSSX-L, send a message to > [hidden email] (not to SPSSX-L), with no body text except the > command. To leave the list, send the command > SIGNOFF SPSSX-L > For a list of commands to manage subscriptions, send the command > INFO REFCARD > ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
| Free forum by Nabble | Edit this page |
