BookmarkSubscribeRSS Feed
nd
Obsidian | Level 7 nd
Obsidian | Level 7

I generated estimates of insurance status that I'd like to show by sex, race, and sex by race. Using PROC PRINT I can see the sex and race alone estimates, then sex by race. However, I want to split VARIABLE so that Uninsured and Insured are across. I can do this using PROC REPORT (see example below). However, I want sex alone to be grouped together  as race alone is grouped before showing sex*race. Is there a way to do this using PROC REPORT? 

 

PROC PRINT output

_ONE_ NEWRACE SEX VARIABLE pct low high flag
1-2-2Uninsured0.19560.18040.2117 
1-2-2Insured0.80440.78830.8196 
*-2MaleUninsured0.23280.20870.2587 
*-2FemaleUninsured0.16180.14320.1823 
*-2MaleInsured0.76720.74130.7913 
*-2FemaleInsured0.83820.81770.8568 
*White, non-Hispanic-2Uninsured0.11180.09260.1343 
*Black, non-Hispanic-2Uninsured0.23890.20570.2755 
*Hispanic-2Uninsured0.29440.26270.3282 
*Asian/PI, non-Hispanic-2Uninsured0.12500.08960.1716 
*Other,non-Hispanic-2Uninsured0.15500.07880.2824*
*White, non-Hispanic-2Insured0.88820.86570.9074 
*Black, non-Hispanic-2Insured0.76110.72450.7943 
*Hispanic-2Insured0.70560.67180.7373 
*Asian/PI, non-Hispanic-2Insured0.87500.82840.9104 
*Other,non-Hispanic-2Insured0.84500.71760.9212*
*White, non-HispanicMaleUninsured0.13670.10760.1722 
*Black, non-HispanicMaleUninsured0.29270.23780.3544 
*HispanicMaleUninsured0.36560.31330.4214 
*Asian/PI, non-HispanicMaleUninsured0.14360.09280.2155 
*Other,non-HispanicMaleUninsured0.22980.09280.4653*
*White, non-HispanicFemaleUninsured0.08610.06350.1156 
*Black, non-HispanicFemaleUninsured0.19610.15790.2410 
*HispanicFemaleUninsured0.23790.20040.2799 
*Asian/PI, non-HispanicFemaleUninsured0.10450.06340.1676 
*Other,non-HispanicFemaleUninsured0.13980.06970.2606*
*White, non-HispanicMaleInsured0.86330.82780.8924 
*Black, non-HispanicMaleInsured0.70730.64560.7622 
*HispanicMaleInsured0.63440.57860.6867 
*Asian/PI, non-HispanicMaleInsured0.85640.78450.9072 
*Other,non-HispanicMaleInsured0.77020.53470.9072*
*White, non-HispanicFemaleInsured0.91390.88440.9365 
*Black, non-HispanicFemaleInsured0.80390.75900.8421 
*HispanicFemaleInsured0.76210.72010.7996 
*Asian/PI, non-HispanicFemaleInsured0.89550.83240.9366 
*Other,non-HispanicFemaleInsured0.86020.73940.9303 

 

PROC REPORT output

 

  Variable  Uninsured Insuredsex race pct low high * pct low high *
-2-20.19560.18040.2117 0.80440.78830.8196 
 White, non-Hispanic0.11180.09260.1343 0.88820.86570.9074 
 Black, non-Hispanic0.23890.20570.2755 0.76110.72450.7943 
 Hispanic0.29440.26270.3282 0.70560.67180.7373 
 Asian/PI, non-Hispanic0.12500.08960.1716 0.87500.82840.9104 
 Other,non-Hispanic0.15500.07880.2824*0.84500.71760.9212*
Male-20.23280.20870.2587 0.76720.74130.7913 
 White, non-Hispanic0.13670.10760.1722 0.86330.82780.8924 
 Black, non-Hispanic0.29270.23780.3544 0.70730.64560.7622 
 Hispanic0.36560.31330.4214 0.63440.57860.6867 
 Asian/PI, non-Hispanic0.14360.09280.2155 0.85640.78450.9072 
 Other,non-Hispanic0.22980.09280.4653*0.77020.53470.9072*
Female-20.16180.14320.1823 0.83820.81770.8568 
 White, non-Hispanic0.08610.06350.1156 0.91390.88440.9365 
 Black, non-Hispanic0.19610.15790.2410 0.80390.75900.8421 
 Hispanic0.23790.20040.2799 0.76210.72010.7996 
 Asian/PI, non-Hispanic0.10450.06340.1676 0.89550.83240.9366 
 Other,non-Hispanic0.13980.06970.2606*0.86020.73940.9303 

 

proc report data=rse headline headskip  ;
	column (sex newrace) variable, (pct low high flag n) ;
	define sex / 'sex' group  order=internal ;
	define newrace / 'race' group order=internal;
	define variable / across nozero order=internal format=ins2f.;
	define pct / nozero format=7.4 ;
	define low / display format=7.4 ;
	define high / display format=7.4 ;
	define flag /'*'  ;
	define n / 'count' noprint;
run;

 

Thanks!

 

1 REPLY 1
Cynthia_sas
SAS Super FREQ

Hi:
Nobody can run your code because you did not provide your format for "variable". Also, I'm having a hard time with your PROC REPORT output because I don't see how the code you've posted could have produced the output you've posted. The column headers don't look right. And, it's not clear to me why you have so many -2 values for NEWRACE and SEX. And this description of what you want "I want sex alone to be grouped together as race alone is grouped before showing sex*race." doesn't make sense to me. You have both SEX and NEWRACE in your column statement so that's what you'll get on the final report. If you want a report that shows sex only or a report that shows newrace only, then that would be a different PROC REPORT step because your column statement would have to change. Here's what I think you want (I used SASHELP.CLASSFIT to make some FAKE data.)

what_I_think_you_mean.png

 

 

  Here's the code I used:

data fakedata;
  length variable $10;
  set sashelp.classfit;
  where age in (12, 13, 14);
  do variable = 'Insured', 'Uninsured';
     output;
  end;
run;
  
proc report data=fakedata;
  column sex variable, (predict height weight);
  define  sex / group;
  define variable / across;
  define predict / mean;
  define height / mean;
  define weight / mean;
run;
  
proc report data=fakedata;
  column age variable, (predict height weight);
  define  age / group;
  define variable / across;
  define predict / mean;
  define height / mean;
  define weight / mean;
run;
 
proc report data=fakedata;
  column sex age variable, (predict height weight);
  define  sex / group;
  define age / group;
  define variable / across;
  define predict / mean;
  define height / mean;
  define weight / mean;
run;



Cynthia

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 1 reply
  • 500 views
  • 0 likes
  • 2 in conversation