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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.