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

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!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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