# extracting values from text

#### jamesmartinn

##### Member
Hi all:

I'm working with a single variable that is free text. I've done a lot of processing on the data with scan and compress and I'm at the final step. I need to do the following:

If I have a variable, called X and is character and has this pattern:

Code:
X
30, 30
how can i extract the information that is delimited by the "," and make it a new entry?

Code:
X
30
30
TIA

#### hlsmith

##### Not a robit
is there one observation or what? X1 = 30, 30, 30,... How about X2 = ??? Confused, the above example would be a transpose of a wide variable?

#### kdt

##### New Member
You can use the countW function to count the number of delimiters, then loop through the values with the scan function.

Code:
   data x ;
length X \$5 ;
str = "12,34,56,5,23,6,7";
do _i_=1 to countC(str,',') ;
x = scan(str,_i_) ;
output ;
end ;
run ;