BookmarkSubscribeRSS Feed
Sami1234
Fluorite | Level 6

Dear All,

 

Would you please help me to achieve something as below?

 

list1 contains a list of continuous and categorical variables altogether & sublist contains only continuous variables. 

If the sublist contains more then 2 variables then 'else do' step runs twice or more.

Would it be possible to put a stop or condition on the 'J'  loop that it should only run once for list1 variables?

 

 

%do i = 1 %to %sysfunc(countw(&list1));

%do j = 1 %to %sysfunc(countw(&sublist));

 

%let main&i. = %scan(&list1,&i,%str( ));

%let sub&j. = %scan(&sublist,&j,%str( ));

 

%if &&main&. = &&sub&j. %then %do;

/*Some steps */

%end;

%else %do;

 

/**other steps**/

 

%end;

%end;

%end;

 

Thank you!

 

1 REPLY 1
Sami1234
Fluorite | Level 6

Actually, it's sorted now by removing the second nested loop. and only comparing the variable list in sublist with the first list.

if yes then first step otherwise the other step.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1 reply
  • 294 views
  • 0 likes
  • 1 in conversation