Data visualization with SAS programming

Displaying actual distribution on graph

Reply
Frequent Contributor
Frequent Contributor
Posts: 94

Displaying actual distribution on graph

Is there an option available to plot (in gplot or any other proc) actual distributions of variables at both the x- and y-axis within the graph which displays y*x plot?
SAS Employee
Posts: 980

Re: Displaying actual distribution on graph

There might be something easier & more automated in the newer ODS graphics, but here are 2 techniques you could use with the traditional SAS/Graph gplot and annotate:

http://robslink.com/SAS/democd8/margin.htm
http://robslink.com/SAS/democd8/margin_info.htm

http://robslink.com/SAS/democd29/mpgsuv.htm
http://robslink.com/SAS/democd29/mpg_info.htm
Frequent Contributor
Frequent Contributor
Posts: 94

Re: Displaying actual distribution on graph

Excellent. Many thanks, Robert.
SAS Super FREQ
Posts: 925

Re: Displaying actual distribution on graph

If you have SAS 9.2, you can run the code below to get what you want. YOu only need to submit the template once. After that, you can run PROC SGRENDER with different data sets and X/Y variables. Let me know if you have any questions.

Thanks!
Dan

proc template;
define statgraph histplot;
dynamic XVAR YVAR;
begingraph;
layout lattice / columndatarange=union columngutter=10 columnweights=(0.75 0.25 ) columns=2
rowdatarange=union rowgutter=10 rowweights=(0.25 0.75 ) rows=2;
layout overlay;
histogram XVAR / binaxis=false name='histogram';
endlayout;
layout overlay;
entry halign=center ' ' / valign=center;
endlayout;
layout overlay;
scatterplot x=XVAR y=YVAR / name='scatter';
endlayout;
layout overlay;
histogram YVAR / binaxis=false name='histogram_h' orient=horizontal;
endlayout;
rowaxes;
rowaxis;
rowaxis;
endrowaxes;
columnaxes;
columnaxis;
columnaxis;
endcolumnaxes;
endlayout;
endgraph;
end;
run;

proc sgrender data=SASHELP.CLASS template=histplot;
dynamic XVAR="weight" YVAR="height";
run;
Frequent Contributor
Frequent Contributor
Posts: 94

Re: Displaying actual distribution on graph

Many thanks, Dan. A very convenient piece of code. Unfortunately, still on 9.1! Will keep this for future.

Vikas
Ask a Question
Discussion stats
  • 4 replies
  • 211 views
  • 0 likes
  • 3 in conversation