BookmarkSubscribeRSS Feed
lalaktgrau
Fluorite | Level 6

Hi all,

 

I have 5 datasets (Cohort1, Cohort2, Cohort3...).

 

I have a long program with a macro variable &DATA whenever I am calling one of the datasets above.

 

Is there a way to write a do loop that will run my entire program on all the cohorts?

1 REPLY 1
Bluebonnet16
Fluorite | Level 6

Hi,

something like this maybe?

 

%macro cohort;

%do i=1 %to 5;

data cohort&i;

infile or set statement here, and you can add &var to create variable different for each year;

 .....

run;

%end;

  

/*you can insert your second macro here that will run for each cohort separately*/

  

%mendcohort;

%cohort;

 

 

 

 

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
  • 1 reply
  • 1239 views
  • 0 likes
  • 2 in conversation