Encapsulated macros can only perform one operation, each time I need a piece of code, sometimes I want to use a macro code to perform multiple loop operations, is this OK? Or is there another solution?
%MACRO EXTRACT(DATANAME,IMPORTNAME,MONTH);
DATA &DATANAME ;
SET &IMPORTNAME;
WHERE MONTH(VAR2)=&MONTH;
SUM+VAR3;
MEAN=SUM/_N_;
KEEP VAR2 VAR3 SUM MEAN;
RUN;
%MEND EXTRACT;
%LET JAN=1;
%LET FEB=2;
%LET MAR=3;
%LET APR=4;
%LET MAY=5;
%LET JUN=6;
%LET JUL=7;
%LET AUG=8;
%LET SEP=9;
%LET OCT=10;
%LET NOV=11;
%LET DEC=12;
%EXTRACT(_201701,FIRST_2017,&JAN);
%EXTRACT(_201702,FIRST_2017,&FEB);
%EXTRACT(_201703,FIRST_2017,&MAR);
%EXTRACT(_201704,FIRST_2017,&APR);
%EXTRACT(_201705,FIRST_2017,&MAY);
%EXTRACT(_201706,FIRST_2017,&JUN);
%EXTRACT(_201707,FIRST_2017,&JUL);
%EXTRACT(_201708,FIRST_2017,&AUG);
%EXTRACT(_201709,FIRST_2017,&SEP);
%EXTRACT(_201710,FIRST_2017,&OCT);
%EXTRACT(_201711,FIRST_2017,&NOV);
%EXTRACT(_201712,FIRST_2017,&DEC);
..........
%EXTRACT(_201901,FIRST_2019,&JAN);
/*This seems too verbose, so what are some ways to make your code more concise*/
🤔🤔🤔
... View more