BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
bncoxuk
Obsidian | Level 7

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Linlin
Lapis Lazuli | Level 10

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

2 REPLIES 2
Linlin
Lapis Lazuli | Level 10

please change 

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

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

Tom
Super User Tom
Super User

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 648 views
  • 3 likes
  • 3 in conversation