BookmarkSubscribeRSS Feed
podarum
Quartz | Level 8

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.

2 REPLIES 2
Cynthia_sas
SAS Super FREQ

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;

Doc_Duke
Rhodochrosite | Level 12

Check out the ODS graphics in PROC NPAR1WAY in SAS 9.3.  It may have what you are looking for.

sas-innovate-2024.png

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.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1347 views
  • 0 likes
  • 3 in conversation