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;

 

 

 

 

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