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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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