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

Hello,

 

First of all, excuse my english, i'm a french student !

 

I find many things on internet but i have a little problem. I want to execute a macro programm many times with differents parameters.

 

This is the code i make with the help of internet and of another subject : https://communities.sas.com/t5/SAS-Programming/how-to-make-a-do-loop-for-running-the-same-code-multi...

 

%macro run_macro (typequest =,nom_fichier_csv=);

%DO i = 1 %to %sysfunc(countw(&typequest));

%let nextvar = %scan(&typequest, &i);
%let nextchemin = %scan(&nom_fichier_csv, &i);

%cim_eer_ev (typequest = &nextvar
,chemin_fichier = &nextchemin
,jour_fin_trim_precedent = &mois_fin_trim_precedent
,mois_fin_trim_precedent = &jour_fin_trim_precedent
,annee_fin_trim_precedent = &annee_fin_trim_precedent )

%END ;

%mend run_macro ;


%run_macro(typequest = cim eer
,nom_fichier_csv= cim_all eer_all
);

It's run well for the first parameters : cim and cim all, but it doesn't loop on the second part (eer and eer_all)...

 

Someone have an idea ?

 

Thank you and really sorry for my english !!

1 ACCEPTED SOLUTION

Accepted Solutions
gamotte
Rhodochrosite | Level 12

Hello,

You don't show the code for macro cim_eer_ev. I suspect that this macro also uses a macrovariable counter &i that overrides the one you use in run_macro. To avoid this type of problem, you have to declare i as %local in each macro.

View solution in original post

2 REPLIES 2
gamotte
Rhodochrosite | Level 12

Hello,

You don't show the code for macro cim_eer_ev. I suspect that this macro also uses a macrovariable counter &i that overrides the one you use in run_macro. To avoid this type of problem, you have to declare i as %local in each macro.

Onizuka
Pyrite | Level 9

Thank you very much, it is working perfectly !!! 😄

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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