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!!!
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
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.
Ready to level-up your skills? Choose your own adventure.