|
I have received multi-mention market research data in the following format -
String 1 2 3 4 5 all in one variable. I want to have numeric with each number in a separate variable. The number of mentions can vary from respondent to respondent. eg Resp 1 1 2 3 4 5 Five mentions Resp 2 3 4 two mentions Is there any syntax/advice out there that someone is prepared to share ? Regards -- Mark Webb +27 21 786 4379 +27 72 199 1000 Skype - webbmark [hidden email] ===================== 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 |
|
Hi,
Is your source file a fixed format ascii like file? You could try to read it like that using the GUI, and generate a syntax that looks something like: GET DATA /TYPE = TXT /FILE = 'C:\temp\somefile.txt' /FIXCASE = 1 /ARRANGEMENT = FIXED /FIRSTCASE = 2 /IMPORTCASE = ALL /VARIABLES = /1 V5 0-0 A1 V2 1-7 A7 V3 8-11 A4 V4 12-51 A40 . CACHE. EXECUTE. If that's not an option, perhaps you can use substrings: compute var1 = number(substr(sourcevar, 1, 1), f1). etc., up to var5 Cheers!! Albert-Jan --- On Fri, 10/2/09, Mark Webb <[hidden email]> wrote: > From: Mark Webb <[hidden email]> > Subject: [SPSSX-L] Parsing in PASW > To: [hidden email] > Date: Friday, October 2, 2009, 12:32 PM > I have received multi-mention market > research data in the following format - > String 1 2 3 4 5 all in > one variable. > I want to have numeric with each number in a separate > variable. > The number of mentions can vary from respondent to > respondent. > eg Resp 1 > 1 2 3 4 5 > Five mentions > Resp > 2 3 4 > two > mentions > > Is there any syntax/advice out there that someone is > prepared to share ? > Regards > > -- > Mark Webb > > +27 21 786 4379 > +27 72 199 1000 > Skype - webbmark > [hidden email] > > ===================== > 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 |
|
In reply to this post by Mark Webb-5
Hi Mark-
I've dealt with things like this before too & took the leap that you'll need at some point both the # of mentions form each respondent & counts for which. The following does both. It is somewhat flexible [put all your other identifiers between "first" and "last"], but might make sense to do a loop / do repeat type solution if you have a much larger set of potential choices than the sample data. Regards, Brian Simply paste all of what is below into a new instance of SPSS in the syntax window to test *****KEEP YOUR ORIGINAL DATA SAFE***** Data list list / thestringvar (a5) . /* read in some sample data . Begin data 123 124 125 1 3 42 15 End data. ***file note - you didn't say if the strings are always concatenations in numerical order, but this solution does not require that compute flag=0. compute #flagFIRST=INDEX(thestringvar,'always empty - just to allow first to last processing')>0. if #flagFIRST=1 flagFIRST=1. form flagFIRST (f1.0). compute flag=0. compute #flagChoice1=INDEX(thestringvar,'1')>0. if #flagChoice1=1 flagChoice1=1. form flagChoice1 (f1.0). compute flag=0. compute #flagChoice2=INDEX(thestringvar,'2')>0. if #flagChoice2=1 flagChoice2=1. form flagChoice2 (f1.0). compute flag=0. compute #flagChoice3=INDEX(thestringvar,'3')>0. if #flagChoice3=1 flagChoice3=1. form flagChoice3 (f1.0). compute flag=0. compute #flagChoice4=INDEX(thestringvar,'4')>0. if #flagChoice4=1 flagChoice4=1. form flagChoice4 (f1.0). compute flag=0. compute #flagChoice5=INDEX(thestringvar,'5')>0. if #flagChoice5=1 flagChoice5=1. form flagChoice5 (f1.0). compute flag=0. compute #flagLAST=INDEX(thestringvar,'always empty - just to allow first to last processing')>0. if #flagLAST=1 flagLAST=1. form flagLAST (f1.0). Freq flagfirst to flaglast. exe. COMPUTE CountNMentions = sum.1(flagFIRST to flagLAST) . EXECUTE . Freq CountNMentions. exe. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Mark Webb Sent: Friday, October 02, 2009 3:32 AM To: [hidden email] Subject: Parsing in PASW I have received multi-mention market research data in the following format - String 1 2 3 4 5 all in one variable. I want to have numeric with each number in a separate variable. The number of mentions can vary from respondent to respondent. eg Resp 1 1 2 3 4 5 Five mentions Resp 2 3 4 two mentions Is there any syntax/advice out there that someone is prepared to share ? Regards -- Mark Webb +27 21 786 4379 +27 72 199 1000 Skype - webbmark [hidden email] ===================== 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 |
