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!!!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.