BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
dmarques1998
Obsidian | Level 7

Hi, 

 

I have 3 different programs, and I want to create a "program 0" that runs all the others programs. However, in the program 1, I want to run him to 36 different months, (i'm using a macro that change every month). Is it possible to run in program 0, 36 times one to each month? if yes, how? 

 

Thank you.  

1 ACCEPTED SOLUTION

Accepted Solutions
yabwon
Onyx | Level 15

Try this shell code and adjust it to your needs:

%macro program0(month);
  %put ##&month.##;
  /*
    put code of your program here
  */
%mend;


%macro loop();
  %do m = 1 %to 36;
    %program0(&m.)
  %end;
%mend;

%loop()

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



View solution in original post

2 REPLIES 2
yabwon
Onyx | Level 15

Try this shell code and adjust it to your needs:

%macro program0(month);
  %put ##&month.##;
  /*
    put code of your program here
  */
%mend;


%macro loop();
  %do m = 1 %to 36;
    %program0(&m.)
  %end;
%mend;

%loop()

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



PaigeMiller
Diamond | Level 26

@dmarques1998 wrote:

 

I have 3 different programs, and I want to create a "program 0" that runs all the others programs. However, in the program 1, I want to run him to 36 different months, (i'm using a macro that change every month). Is it possible to run in program 0, 36 times one to each month? if yes, how? 


You could modify the macro to do the looping 36 times, or some arbitrary number of times that would be specified in the argument to the macro. You don't really need another macro to do this, although of course that works.

--
Paige Miller

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 2 replies
  • 941 views
  • 3 likes
  • 3 in conversation