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.
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
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
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: