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;
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;
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;
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;
Thank you! You guys are awesome!!!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.