How can I compare 2 distributions graphically.. I have 2 different datasets of the same variable and I'd like to compare that variable in Set1 with the same variable in Set2.
Thanks.
Hi:
If you have SAS 9.2 or higher, you can use PROC SGPANEL to give you a nice graph. For example, in the program below, I use SASHELP.CLASS and then make a "fake" dataset called WORK.CLASS2 and make 1 new dataset called WORK.BOTHCLASSES with a DATAFILE variable as an identifier. Then I use PROC SGPANEL with a PANELBY statement to show two histograms for AGE side by side.
cynthia
data class2;
set sashelp.class;
** create a different age value ;
** for second dataset;
age=age+2;
run;
data bothclasses(keep=name age datafile);
** now make a variable to represent the datafile;
set sashelp.class(in=inone)
work.class2(in=intwo);
if inone = 1 then datafile='SASHELP.CLASS';
if intwo = 1 then datafile='WORK.CLASS2';
run;
ods listing close;
ods pdf file='c:\temp\panel_hist.pdf';
proc sgpanel data=bothclasses;
title 'Compare Two Histograms';
** use PANELBY to show each data sets info;
** in a separate panel using HISTOGRAM statement;
panelby datafile;
histogram age / binstart=11 ;
density age;
density age / type=kernel;
colaxis values=(11 to 18 by 1);
run;
ods pdf close;
Check out the ODS graphics in PROC NPAR1WAY in SAS 9.3. It may have what you are looking for.
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.