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;

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

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