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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 1646 views
  • 0 likes
  • 2 in conversation