BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ger15xxhcker
Quartz | Level 8

Hi!

 

I want to go through the elements of a list but there is a dot in the name of the elements of the list and there it separates the elements of the list I only want to separate them along the spaces.

 

 

%macro px;

%let value = x.yy a.yy;
%local i next_value;
%let i=1;
%do %while (%scan(&value, &i) ne );
   %let next_value = %scan(&value, &i);
%put &next_value;
%let i = %eval(&i + 1);
%end;
%mend; %px;

I get this :

 

x
yy
a
yy
 
I want this:
x.yy
a.yy
 
Thanks!
 
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

You have to specifically tell the SCAN function to only use spaces as word delimiter, and not spaces plus periods plus other special symbols (which is the default). Modify these two lines as shown

 

%do %while (%scan(&value, &i) ne %str( ));
   %let next_value = %scan(&value, &i, %str( ));
--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

You have to specifically tell the SCAN function to only use spaces as word delimiter, and not spaces plus periods plus other special symbols (which is the default). Modify these two lines as shown

 

%do %while (%scan(&value, &i) ne %str( ));
   %let next_value = %scan(&value, &i, %str( ));
--
Paige Miller

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 826 views
  • 2 likes
  • 2 in conversation