BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
vacummyouyou
Fluorite | Level 6

Hi,

How do I fill color under density curves? Here are my sample data and sgpanel procedure. TIA!

 

/* Sample data */
data mydata;
input group $ value;
datalines;
A 10
A 12
A 13
B 9
B 11
B 14
C 8
C 10
C 11
;
run;

/* Creating the panelled density plot */
proc sgpanel data=mydata;
panelby group / layout=rowlattice columns=1 novarname;
density value;
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
ods select none;
proc sgpanel data=sashelp.heart;
panelby bp_status / layout=rowlattice columns=1 novarname;
density weight;
ods output sgpanel=sgpanel;
run;
ods select all;

proc sgpanel data=sgpanel noautolegend;
panelby bp_status / layout=rowlattice columns=1 novarname;
series x=NORMLD_WEIGHT____X y=NORMLD_WEIGHT____Y /lineattrs=(thickness=2) group=bp_status;
band x=NORMLD_WEIGHT____X lower=0 upper=NORMLD_WEIGHT____Y/transparency=0.8 group=bp_status;
run;

Ksharp_0-1715654685794.png

 

View solution in original post

3 REPLIES 3
Ksharp
Super User
ods select none;
proc sgpanel data=sashelp.heart;
panelby bp_status / layout=rowlattice columns=1 novarname;
density weight;
ods output sgpanel=sgpanel;
run;
ods select all;

proc sgpanel data=sgpanel noautolegend;
panelby bp_status / layout=rowlattice columns=1 novarname;
series x=NORMLD_WEIGHT____X y=NORMLD_WEIGHT____Y /lineattrs=(thickness=2) group=bp_status;
band x=NORMLD_WEIGHT____X lower=0 upper=NORMLD_WEIGHT____Y/transparency=0.8 group=bp_status;
run;

Ksharp_0-1715654685794.png

 

Rick_SAS
SAS Super FREQ

You can also get a panel by using PROC UNIVARIATE. PROC UNIVARIATE does not enable you to control all aspects of the plot, but for a quick visualization, it suffices. For publication-quality graphics, I think KSharp's idea enables more control.

 

proc univariate data=mydata;
   class group;
   var value;
   histogram value / normal(fill) nobars nrow=3 nocurvelegend; 
   ods select Histogram;
run;
vacummyouyou
Fluorite | Level 6

Thank you! You guys are awesome!!!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 3 replies
  • 234 views
  • 9 likes
  • 3 in conversation