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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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