BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
TomHsiung
Lapis Lazuli | Level 10

Hi, guys

 

I expand my research of PDF graph to two variables. Here is my code.

 

data Have; set Sample2(keep=weight inf_weight); run;
   proc kde data=Have;
     bivar weight inf_weight / bwm=2 ngrid=250 plots=contour;
     score data=Have out=Out(rename=(value1=weight value2=inf_weight));
   run;
   proc sort data=Out;  by density;  run;
   proc sgplot data=Out;
      styleattrs wallcolor=white;
      scatter x=weight y=inf_weight / colorresponse=density colormodel=ThreeColorRamp
                         markerattrs=(symbol=CircleFilled) transparency=0.5;
      xaxis grid values=(30 to 150); 
      yaxis grid values=(500 to 6000);
   run;

This will produce a scatter plot and the value of PDFs is represented by the color.

Unknown-3.png

 

If I intend to know the area that corresponds to a probability mass of 95%, how do I get it and mark the area on the graph? I know there is another type of graph called surface plot which uses the volume to represent the probability mass but that's not my consideration. Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Check @Rick_SAS  blogs:

https://blogs.sas.com/content/iml/2014/07/21/add-prediction-ellipse.html

https://blogs.sas.com/content/iml/2014/07/23/prediction-ellipses-from-covariance.html

 



data Have; set sashelp.heart(keep=weight height); run;
   proc kde data=Have ;
     bivar weight height /out=out(rename=(value1=weight value2=height)) bwm=2 ngrid=250  plots=contour;
   run;
   proc sort data=Out;  by density;  run;

   data out2;
    set out have(keep=weight height rename=(weight=weight2 height=height2));
run;


   proc sgplot data=Out2;
      styleattrs wallcolor=white;
      scatter x=weight y=height / colorresponse=density colormodel=ThreeColorRamp
                         markerattrs=(symbol=CircleFilled) transparency=0.5;
	   ellipse x=weight2 y=height2;           /* default is ALPHA=0.05 */

   run;

Ksharp_0-1748226346751.png

 

View solution in original post

2 REPLIES 2
Ksharp
Super User

Check @Rick_SAS  blogs:

https://blogs.sas.com/content/iml/2014/07/21/add-prediction-ellipse.html

https://blogs.sas.com/content/iml/2014/07/23/prediction-ellipses-from-covariance.html

 



data Have; set sashelp.heart(keep=weight height); run;
   proc kde data=Have ;
     bivar weight height /out=out(rename=(value1=weight value2=height)) bwm=2 ngrid=250  plots=contour;
   run;
   proc sort data=Out;  by density;  run;

   data out2;
    set out have(keep=weight height rename=(weight=weight2 height=height2));
run;


   proc sgplot data=Out2;
      styleattrs wallcolor=white;
      scatter x=weight y=height / colorresponse=density colormodel=ThreeColorRamp
                         markerattrs=(symbol=CircleFilled) transparency=0.5;
	   ellipse x=weight2 y=height2;           /* default is ALPHA=0.05 */

   run;

Ksharp_0-1748226346751.png

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 2 replies
  • 1120 views
  • 4 likes
  • 2 in conversation