Help using Base SAS procedures

simple macro: syntax error

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 131
Accepted Solution

simple macro: syntax error

SAS said there is syntax error for &j:

%MACRO calnum;
  %DO j=1 %TO 2;
  %DO i=1 %TO 10;
     PROC UNIVARIATE DATA=work.data&j;
       VAR diff;
       OUTPUT OUT=work.pctile&j%SYSFUNC(PUTN(&i,z2.)) PCTLPRE=P&j_ PCTLPTS=1 to 100 BY 1;
     RUN;
  %END;
  %END;
%MEND;

It seemed that the use of work.data&j is fine, but it is error to specify it as: PCTLPRE=P&j_  

How can I put this right?


Accepted Solutions
Solution
‎11-22-2011 11:21 AM
Super Contributor
Posts: 1,636

simple macro: syntax error

please change 

PCTLPRE=P&j_ PCTLPTS=1 to 100 BY 1; to

PCTLPRE=P&j._ PCTLPTS=1 to 100 BY 1;

View solution in original post


All Replies
Solution
‎11-22-2011 11:21 AM
Super Contributor
Posts: 1,636

simple macro: syntax error

please change 

PCTLPRE=P&j_ PCTLPTS=1 to 100 BY 1; to

PCTLPRE=P&j._ PCTLPTS=1 to 100 BY 1;

Super User
Super User
Posts: 7,079

simple macro: syntax error

LinLin's answer should solve the problem.  SAS will interpret &J_ as a request to expand the non existent macro variable named J_.  Placing the period after the J will let SAS know that you want to expand the value of the macro variable J instead.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 134 views
  • 3 likes
  • 3 in conversation