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

Wasn't sure whether to post this here or under the Macro section - but it's here!

This code works as expected:

axis1 label=none value=(h=1.5;;

proc gchart data=barsall;

vbar period/sumvar=pct

maxis=axis1

;

run;

When I attempt to change axis1 into a macro variable (for automation), I get an error whose cause I don't understand.  Code and log below.  Please help me to eliminate the error.  Thanks, Bill

%let axis1=label=none value=(h=1.5);

proc gchart data=barsall;

vbar period/sumvar=pct

maxis=&axis1

;

run;

Log follows

30151 %let axis1=label=none value=(h=1.5);

 

30152 proc gchart data=barsall;

NOTE: The previous statement has been deleted.

30153 vbar period/sumvar=pct

30154 maxis=&axis1

30155 ;

NOTE: Line generated by the macro variable "AXIS1".

30155 label=none value=(h=1.5)

-

22

76

ERROR 22-322: Syntax error, expecting one of the following: ;, ANNOTATE, ASCENDING, AUTOREF, CAUTOREF, CAXIS, CERROR, CFRAME, CFREQ, CLIPREF, CLM, COUTLINE, CPERCENT, CR, CREF, CTEXT, DESCENDING, DESCRIPTION, DISCRETE, ERRORBAR, FRAME, FREQ,

FRONTREF, G100, GAXIS, GROUP, GSPACE, HMINOR, HREF, HTML, HTML_LEGEND, IFRAME, IMAGESTYLE, INSIDE, LAUTOREF, LEGEND, LEVELS, LR, LREF, MAXIS, MEAN, MIDPOINTS, MINOR, MISSING, NAME, NOAXIS, NOBASEREF, NOFRAME, NOHEADING,

NOLEGEND, NOSPACE, NOZERO, OUTSIDE, PATTERNID, PERCENT, RANGE, RAXIS, REF, SPACE, SUBGROUP, SUM, SUMVAR, TYPE, VMINOR, VREF, WIDTH, WOUTLINE.

ERROR 76-322: Syntax error, statement will be ignored.

30156 run;

1 ACCEPTED SOLUTION

Accepted Solutions
GraphGuy
Meteorite | Level 14

There are probably several ways, but one way to do it is like this:

%let axis1txt=label=none value=(h=1.5);

axis1 &axis1txt;

proc gchart data=sashelp.class;
vbar height / discrete
type=sum sumvar=age maxis=axis1;
run;

View solution in original post

5 REPLIES 5
GraphGuy
Meteorite | Level 14

There are probably several ways, but one way to do it is like this:

%let axis1txt=label=none value=(h=1.5);

axis1 &axis1txt;

proc gchart data=sashelp.class;
vbar height / discrete
type=sum sumvar=age maxis=axis1;
run;

Bill
Quartz | Level 8

Thanks Rob;

Is the problem then that we cannot use a macro variable directly with maxis= as in maxis=&axis1?

Bill

GraphGuy
Meteorite | Level 14

Here's the doc:

http://support.sas.com/documentation/cdl/en/graphref/63022/HTML/default/viewer.htm#gchart-bar.htm

"MAXIS=AXIS<1...99> assigns the specified AXIS definition to the midpoint axis."

maxis must point to a numbered axis<1..99> (not the values that would be defined in that axis statement)...

MikeZdeb
Rhodochrosite | Level 12

I think that one way to see why this will not work is to show what you are trying  to do with that macro variable.  Your PROC looks like this after the SAS macro processor substitutes the macro text ...

proc gchart data=barsall;

vbar period/sumvar=pct

maxis=label=none value=(h=1.5);

run;

Once the text is subsituted, the compiler looks at your SAS job and finds the errors.  If you look at that PROC, I do not think that you would write anything that looks like that.  As Robert Allison pointed out, all you can have after MAXIS= is the name of an axis definition, for example MAXIS=AXIS1 (you cannot have a set of instructions and that's what you are trying to do).

Bill
Quartz | Level 8

Mike - you are most correct.  It's so obvious that I should have seen it.  Your response actually made me realize that axis statements (and various others) behave like macro variables in a substitutionary sense.

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 5 replies
  • 1202 views
  • 6 likes
  • 3 in conversation