Break string variable

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Break string variable

Samir Omerovic

 Hi to all,
 
could anyone suggest a syntax that would break string variable into few numeric ones? I have string variable that contains numbers delimited with ";". However there is no fixed number of  ";" in the variable. It may vary from 1 to 10. So basically I would need to break one string variable into maximum of 10 numeric variables.
For example the value of variable q11 (1; 2; 4; 55; 6; 7; 88;) should be transformed into 7 variables with values 1, 2, 4, 55, 6, 7, 88 etc.
 
Thanks for the help
 
Samir
Reply | Threaded
Open this post in threaded view
|

Re: Break string variable

Maguin, Eugene
Samir,

>>could anyone suggest a syntax that would break string variable into few
numeric ones? I have string variable that contains numbers delimited with
";". However there is no fixed number of  ";" in the variable. It may vary
from 1 to 10. So basically I would need to break one string variable into
maximum of 10 numeric variables.
For example the value of variable q11 (1; 2; 4; 55; 6; 7; 88;) should be
transformed into 7 variables with values 1, 2, 4, 55, 6, 7, 88 etc.

1) Your example shows that '; ', semicolon-space, is the separator between
numbers. Is that absolutely always true or are there some values with
(1;2;4;55;6;7;88;) and some with (1; 2; 4; 55; 6; 7; 88;) and some with
(1;2; 4;55; 6; 7;88;).

2) Your example shows that a semicolon follows the last number. Is that
absolutely always true?

3) Your example shows that parentheses enclose the string. Is the parenthese
truly there in the dataset or are you just using those symbols to delineate
the string in your message?

Basically, how much structure is in the strings that will need to be taken
into account in the extraction process.

Thanks, Gene Maguin

=====================
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