|
Dear List,
I am in the midst of trying to extract some data from an online survey we've been conducting. In this survey we have several variables where people were allowed to enter text (e.g. they had to write the sports they participate in). Some of the participants have written a text that contains carriage returns (e.g. when they have separated three different types of sport by a carriage return). Is it possible to make a syntax that searches through a string variable and creates a number of new variables with the text that is separated by each of the carriage return for each participant? I believe the clue to this must be the INDEX or RINDEX command but can anyone give me an example of how it works and how to search for a carriage return. Best regards, Claus D. Hansen Department of Occupational Medicine Herning Hospital Denmark ===================== 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 Claus,
Did you try reading the source file using GET DATA, and with DELIMITERS = '/t,' / ARRANGEMENT = DELIMITED? Cheers!! Albert-Jan --- "Claus D. Hansen" <[hidden email]> wrote: > Dear List, > > I am in the midst of trying to extract some data > from an online survey > we've been conducting. In this survey we have > several variables where > people were allowed to enter text (e.g. they had to > write the sports they > participate in). > > Some of the participants have written a text that > contains carriage > returns (e.g. when they have separated three > different types of sport by a > carriage return). > > Is it possible to make a syntax that searches > through a string variable > and creates a number of new variables with the text > that is separated by > each of the carriage return for each participant? I > believe the clue to > this must be the INDEX or RINDEX command but can > anyone give me an example > of how it works and how to search for a carriage > return. > > Best regards, > > Claus D. Hansen > Department of Occupational Medicine > Herning Hospital > Denmark > > ===================== > 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 > ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ ===================== 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 Claus D. Hansen
Hello Albert-Jan,
and thank you for the suggestion. Unfortunately it doesn't seem to work. The trouble is that there are carriage returns in the middle of the text string which is delimited by " " defining it as text. Each variable is delimited by semi-colons. So I can import the file into SPSS format but ends up with the string variable containing carriage returns. Shouldn't there be some way of creating a syntax that would let you search for these carriage returns - using the INDEX commando? Another possibility would be to use the find and replace function in Excel. However I can't seem to get it to search for carriage return - but if anyone knows how to do this I'd be very grateful. Thank you in advance, Claus > -----Original Message----- > From: Albert-jan Roskam [mailto:[hidden email]] > Sent: 14. februar 2008 14:37 > To: Claus D. Hansen; [hidden email] > Subject: Re: Extracting parts of string variables separated by carriage > returns > > Hi Claus, > > Did you try reading the source file using GET DATA, > and with DELIMITERS = '/t,' / ARRANGEMENT = DELIMITED? > > > Cheers!! > Albert-Jan > > --- "Claus D. Hansen" <[hidden email]> wrote: > > > Dear List, > > > > I am in the midst of trying to extract some data > > from an online survey > > we've been conducting. In this survey we have > > several variables where > > people were allowed to enter text (e.g. they had to > > write the sports they > > participate in). > > > > Some of the participants have written a text that > > contains carriage > > returns (e.g. when they have separated three > > different types of sport by a > > carriage return). > > > > Is it possible to make a syntax that searches > > through a string variable > > and creates a number of new variables with the text > > that is separated by > > each of the carriage return for each participant? I > > believe the clue to > > this must be the INDEX or RINDEX command but can > > anyone give me an example > > of how it works and how to search for a carriage > > return. > > > > Best regards, > > > > Claus D. Hansen > > Department of Occupational Medicine > > Herning Hospital > > Denmark > > > > ===================== > > 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 > > > > > > > _______________________________________________________________________ > _____________ > Be a better friend, newshound, and > know-it-all with Yahoo! Mobile. Try it now. > http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ ===================== 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 |
|
Yes you can do that. BTW, if you change the format of a variable from, say, A100 to AHEX200, you can see the actual character codes. Most likely these will be carriage return/line feed, but they could be just CR or just LF.
However, this is a bit tricky, because you can't put literal CRLF in your syntax or you will break something. This code should get you started. compute strvar = replace(strvar, string(10, ib1),'!'). compute strvar = replace(strvar, string(13, ib1),'!'). It turns the cr lf sequence into !! Then you can split these up as needed. The ib format allows you to enter the numerical code for a character. HTH, Jon Peck -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Claus D. Hansen Sent: Thursday, February 14, 2008 11:10 AM To: [hidden email] Subject: Re: [SPSSX-L] Extracting parts of string variables separated by carriage returns Hello Albert-Jan, and thank you for the suggestion. Unfortunately it doesn't seem to work. The trouble is that there are carriage returns in the middle of the text string which is delimited by " " defining it as text. Each variable is delimited by semi-colons. So I can import the file into SPSS format but ends up with the string variable containing carriage returns. Shouldn't there be some way of creating a syntax that would let you search for these carriage returns - using the INDEX commando? Another possibility would be to use the find and replace function in Excel. However I can't seem to get it to search for carriage return - but if anyone knows how to do this I'd be very grateful. Thank you in advance, Claus > -----Original Message----- > From: Albert-jan Roskam [mailto:[hidden email]] > Sent: 14. februar 2008 14:37 > To: Claus D. Hansen; [hidden email] > Subject: Re: Extracting parts of string variables separated by carriage > returns > > Hi Claus, > > Did you try reading the source file using GET DATA, > and with DELIMITERS = '/t,' / ARRANGEMENT = DELIMITED? > > > Cheers!! > Albert-Jan > > --- "Claus D. Hansen" <[hidden email]> wrote: > > > Dear List, > > > > I am in the midst of trying to extract some data > > from an online survey > > we've been conducting. In this survey we have > > several variables where > > people were allowed to enter text (e.g. they had to > > write the sports they > > participate in). > > > > Some of the participants have written a text that > > contains carriage > > returns (e.g. when they have separated three > > different types of sport by a > > carriage return). > > > > Is it possible to make a syntax that searches > > through a string variable > > and creates a number of new variables with the text > > that is separated by > > each of the carriage return for each participant? I > > believe the clue to > > this must be the INDEX or RINDEX command but can > > anyone give me an example > > of how it works and how to search for a carriage > > return. > > > > Best regards, > > > > Claus D. Hansen > > Department of Occupational Medicine > > Herning Hospital > > Denmark > > > > ===================== > > 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 > > > > > > > _______________________________________________________________________ > _____________ > Be a better friend, newshound, and > know-it-all with Yahoo! Mobile. Try it now. > http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ ===================== 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 |
