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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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 lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1401 views
  • 9 likes
  • 3 in conversation