|
Hello,
I have a string variable that has values 130/78, 140/90, 150/95, etc. I want to break this variable into 2 so that the new values are var1 var2 var 3 130/78 130 78 140/90 140 90 150/95 150 95 Thanks for your assistance. ===================== 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 |
|
This will create two numeric variables (the code would actually be simpler to create two strings, but numbers are more useful that strings).
data list free /var1 (a6). begin data 130/78 140/90 150/95 end data. compute #index=index(var1, "/"). compute var2=number(substr(var1, 1, #index-1),f3). compute var3=number(substr(var1, #index+1), f3). list. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Zahid Abbas Sent: Wednesday, April 09, 2008 2:38 PM To: [hidden email] Subject: breaking string variable Hello, I have a string variable that has values 130/78, 140/90, 150/95, etc. I want to break this variable into 2 so that the new values are var1 var2 var 3 130/78 130 78 140/90 140 90 150/95 150 95 Thanks for your assistance. ===================== 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 |
|
Thanks so much Richard!> Date: Wed, 9 Apr 2008 14:53:46 -0500> From: [hidden email]> Subject: Re: breaking string variable> To: [hidden email]> > This will create two numeric variables (the code would actually be simpler to create two strings, but numbers are more useful that strings).> > data list free /var1 (a6).> begin data> 130/78> 140/90> 150/95> end data.> compute #index=index(var1, "/").> compute var2=number(substr(var1, 1, #index-1),f3).> compute var3=number(substr(var1, #index+1), f3).> list.> > -----Original Message-----> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Zahid Abbas> Sent: Wednesday, April 09, 2008 2:38 PM> To: [hidden email]> Subject: breaking string variable> > Hello,> I have a string variable that has values 130/78, 140/90, 150/95, etc. I> want to break this variable into 2 so that the new values are> > var1 var2 var 3> 130/78 130 78> 140/90 140 90> 150/95 150 95> > Thanks for your assistance.> > =====================> 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
_________________________________________________________________ Enter today for your chance to win $1000 a day—today until May 12th. Learn more at SignInAndWIN.ca http://g.msn.ca/ca55/215 ====================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 |
