BookmarkSubscribeRSS Feed
jysaho
Calcite | Level 5

I got the following error after running the code with discreteattrmap. Below is my code.

 

I am using SAS 9.4 TS Level 1M3.

 

I appreciate if anyone could help me solve by this weekend (my project due next week).

-----------------------------------------------------------------------------------------------------------

ods graphics on;
proc template;
define statgraph Base.Freq.Graphics.StackedPercentChart;
/* more code here */
discreteattrmap name="colors" / ignorecase=true;
value "Hybrid" / fillattrs=(color=orange );
value "SUV" / fillattrs=(color=blue);
value "Sedan" / fillattrs=(color=green );
value "Sports" / fillattrs=(color=red);
value "Truck" / fillattrs=(color=yellow);
value "Wagon" / fillattrs=(color=pink);
enddiscreteattrmap;
discreteattrvar attrvar=_row var=_row attrmap="colors";
/* more code here */
barchartparm x=_COLVAR y=_PLOTVAR / segmentlabelformat=4.1
segmentlabeltype=auto group=_row name="Rows"
groupdisplay=_CLUSTER datatransparency=.5 rolename=(tip4=_FREQ)
tip=(group x y tip4);
/* more code here */
end;
run;

proc freq data=sashelp.cars;
tables drivetrain*type*origin /plots=freqplot(twoway=stacked
scale=grouppct);
run;

 

 

-------------------------------------------------------------------------------------------------------

ERROR 180-322: Statement is not valid or it is used out of proper order.

2 REPLIES 2
SuryaKiran
Meteorite | Level 14

It doesn't look like it applies to SASHELP.CARS dataset. Some of the variables you mentioned doesn't exist in that table. 

 

ods graphics on;
proc template;
define statgraph Base.Freq.Graphics.StackedPercentChart;
begingraph;	/* Added */
discreteattrmap name="colors" / ignorecase=true;
value "Hybrid" / fillattrs=(color=orange );
value "SUV" / fillattrs=(color=blue);
value "Sedan" / fillattrs=(color=green );
value "Sports" / fillattrs=(color=red);
value "Truck" / fillattrs=(color=yellow);
value "Wagon" / fillattrs=(color=pink);
enddiscreteattrmap;
discreteattrvar attrvar=_row var=_row attrmap="colors";
layout overlay;/* Added */
barchartparm x=TYPE y=_PLOTVAR / segmentlabelformat=4.1 /* X and Y values here depends on your dataset */
segmentlabeltype=auto group=_row name="Rows"
groupdisplay=CLUSTER datatransparency=.5 rolename=(tip4=_FREQ_) /* CLUSTER */
tip=(group x y tip4);
endlayout; /* Added */
endgraph;/* Added */
end;
run;

Check this document to learn more on how to create template.

https://support.sas.com/documentation/cdl/en/grstatug/63302/PDF/default/grstatug.pdf

Thanks,
Suryakiran
ballardw
Super User

Copy the code and error message from the log.

Paste the copied code and messages into a code box opened on the forum using the {I}. That error message you reference usually has a diagnostic underscore indicating where SAS found the error. Pasting into the code box will maintain the appearance of the log with the underscore. The main message windows here will reformat text, which you may have noticed if you indent code at all.

 

Attempting to replace SAS supplied templates such as here:

define statgraph Base.Freq.Graphics.StackedPercentChart;

might be the issue. Did you define an PATH statement, either in Proc Template or ODS PATH to write the resulting object to other than SASUSER.Templat (the default for such templates 

 

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
  • 2 replies
  • 752 views
  • 0 likes
  • 3 in conversation