Hi all, @I'm pretty green to SAS and SAS EG. I try to define macro within macro but turns out I got the problem as described in 'MACRO within a MACRO problems' MACRO within a MACRO problems. , that no lines underneath the MEND statement, which means SAS enhanced editor fail to identify the code block. I understand that it's a bad practice to write macro within macro but I'm doing so to reduce the numbers of codes as I need to create a lot of similar subqueries that is having the same select and joining clause(or same clause applying to different tables, the idea is that the code are similar and I want to write them in one macro). Is there a way to tell the SAS editor where the code ends so that it can be collapsed for easier navigation? Or what is the correct way to write macro within macro so that I won't encounter this problem? My high level example code is as follow: %macro M1(code); %if code=1 %then %do; %macro whereclause(); Where t1.c3=A1 and t1.c4=B1 %mend whereclause(); %macro groupclause(); Group by t1.c3, t1.c4 %mend groupclause(); %end; %if code=2 %then %do; %macro whereclause(); Where t1.c3=A2 and t1.c4=B2 and t1.c4=D2 %mend whereclause(); %macro groupclause(); Group by t1.c3, t1.c4, t1.c5 %mend groupclause(); %end; . . . (select t1.c1, t1.c2, t1.c3, t1.c4, t1.c5, max(t1.c2) as c6 from t1 inner t2 on t1.c1=t2.c1 and t1.c2=t2.c2 %whereclause() %groupclause() ) %mend M1; Thanks and regards, Peter
... View more