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

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