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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 952 views
  • 0 likes
  • 3 in conversation