BookmarkSubscribeRSS Feed
csetzkorn
Lapis Lazuli | Level 10

Looking at this:

 

https://blogs.sas.com/content/graphicallyspeaking/2012/02/06/comparative-densities/

 

title 'Mileage Distribution by Origin';
proc sgplot data=multiVar;
density mpg_usa / legendlabel='USA' lineattrs=(pattern=solid);
density mpg_asia / legendlabel='Asia' lineattrs=(pattern=solid);
density mpg_eur / legendlabel='Europe' lineattrs=(pattern=solid);
keylegend / location=inside position=topright across=1;
xaxis display=(nolabel);
run;

 

Here mpg_usa, mpg_asia and mpg_eur are separate columns. Can I also create separate plots like this if I have one column X and one group/class column in one plot? Hope this makes sense?

4 REPLIES 4
Jay54
Meteorite | Level 14

Yes.  Density plot supports GROUP option.  The option was added after the writing of this example.

 

title 'Mileage Distribution by Origin';
proc sgplot data=sashelp.cars;
  density mpg_city / group=origin lineattrs=(pattern=solid);
  keylegend / location=inside position=topright across=1;
  xaxis display=(nolabel);
run;
csetzkorn
Lapis Lazuli | Level 10

I have the suspicion that this is a 9.4 SAS version feature as I am getting:

 

ERROR 22-322: Syntax error, expecting one of the following: ;, FREQ, LEGENDLABEL, LINEATTRS, NAME, SCALE, TRANSPARENCY, TYPE,
X2AXIS, Y2AXIS.
ERROR 76-322: Syntax error, statement will be ignored.

 

with an older version of sas ...

Jay54
Meteorite | Level 14

Yes.  9.40M2.  2015.

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
  • 4 replies
  • 5670 views
  • 1 like
  • 3 in conversation