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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1025 views
  • 1 like
  • 3 in conversation