BookmarkSubscribeRSS Feed
daniele_1306
Calcite | Level 5
I have a text field with the words delimited by; .
the number of words is fixed.
how can I extract all the words from the text field? 
ex:
Row 01: 299999;Pippo;45.89;Pluto;Sas
Row 02: 7777;George;4567.2;David;Enterprise

2 REPLIES 2
Jagadishkatam
Amethyst | Level 16
May we know if you want words in separate columns/variables or in a single variable
Thanks,
Jag
PeterClemmensen
Tourmaline | Level 20

Do something like this and extract the values you consider a 'word'

 

data have;
length string $100;
string="299999;Pippo;45.89;Pluto;Sas";output;
string="7777;George;4567.2;David;Enterprise";output;
run;

data want;
   set have;
   do i=1 to countw(string, ';');
      word=scan(string, i, ';');
      output;
   end;
run;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 563 views
  • 1 like
  • 3 in conversation