07-17-2017 11:30 PM
I am very new in SAS.
I am trying to loop a SAS macro.
%let E1 = APPLE;
%let E2 = YAHOO;
%let E3 = SAS;
%MARCO FILTER_NAME(VAR1=. VAR2=);
%do i=1 %to 3;
%FILTER_NAME(VAR1=filename_&&E&i, VAR2 = output_filename_&&E&i ) /*trying to pass the variable E1 with name Apple inside here*/
Something is wrong above. Anybody know how?
07-17-2017 11:48 PM
If you are just starting to learn SAS then you should first concentrate on learning how to write SAS code. Once you know how to write SAS code you could then begin to learn how to use the SAS macro language to tell SAS how to write the SAS code for you.
That being said your program looks basically ok. There are a couple of typos. But perhaps the main missing thing is that there you never call the macro that you defined.
%let E1 = APPLE; %let E2 = YAHOO; %let E3 = SAS; %MACRO FILTER_NAME(VAR1,VAR2); %put VAR1=&var1; %put VAR2=&var2; %MEND FILTER_NAME; %MACRO LOOP; %do i=1 %to 3; %FILTER_NAME(VAR1=filename_&&E&i, VAR2 = output_filename_&&E&i ) %end; %MEND LOOP; %loop;
a month ago
While Tom is 100% correct about learning SAS language before learning macro language, here are some secondary considerations.
The problem may lie inside the definition of %FILTER_NAME. Some possibilities:
If you were to post more of what is inside your macro, you may find you receive more than debugging help ... how to achieve the same result in a cleaner, more efficient way.