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
1 | -2 | -2 | Uninsured | 0.1956 | 0.1804 | 0.2117 | |
1 | -2 | -2 | Insured | 0.8044 | 0.7883 | 0.8196 | |
* | -2 | Male | Uninsured | 0.2328 | 0.2087 | 0.2587 | |
* | -2 | Female | Uninsured | 0.1618 | 0.1432 | 0.1823 | |
* | -2 | Male | Insured | 0.7672 | 0.7413 | 0.7913 | |
* | -2 | Female | Insured | 0.8382 | 0.8177 | 0.8568 | |
* | White, non-Hispanic | -2 | Uninsured | 0.1118 | 0.0926 | 0.1343 | |
* | Black, non-Hispanic | -2 | Uninsured | 0.2389 | 0.2057 | 0.2755 | |
* | Hispanic | -2 | Uninsured | 0.2944 | 0.2627 | 0.3282 | |
* | Asian/PI, non-Hispanic | -2 | Uninsured | 0.1250 | 0.0896 | 0.1716 | |
* | Other,non-Hispanic | -2 | Uninsured | 0.1550 | 0.0788 | 0.2824 | * |
* | White, non-Hispanic | -2 | Insured | 0.8882 | 0.8657 | 0.9074 | |
* | Black, non-Hispanic | -2 | Insured | 0.7611 | 0.7245 | 0.7943 | |
* | Hispanic | -2 | Insured | 0.7056 | 0.6718 | 0.7373 | |
* | Asian/PI, non-Hispanic | -2 | Insured | 0.8750 | 0.8284 | 0.9104 | |
* | Other,non-Hispanic | -2 | Insured | 0.8450 | 0.7176 | 0.9212 | * |
* | White, non-Hispanic | Male | Uninsured | 0.1367 | 0.1076 | 0.1722 | |
* | Black, non-Hispanic | Male | Uninsured | 0.2927 | 0.2378 | 0.3544 | |
* | Hispanic | Male | Uninsured | 0.3656 | 0.3133 | 0.4214 | |
* | Asian/PI, non-Hispanic | Male | Uninsured | 0.1436 | 0.0928 | 0.2155 | |
* | Other,non-Hispanic | Male | Uninsured | 0.2298 | 0.0928 | 0.4653 | * |
* | White, non-Hispanic | Female | Uninsured | 0.0861 | 0.0635 | 0.1156 | |
* | Black, non-Hispanic | Female | Uninsured | 0.1961 | 0.1579 | 0.2410 | |
* | Hispanic | Female | Uninsured | 0.2379 | 0.2004 | 0.2799 | |
* | Asian/PI, non-Hispanic | Female | Uninsured | 0.1045 | 0.0634 | 0.1676 | |
* | Other,non-Hispanic | Female | Uninsured | 0.1398 | 0.0697 | 0.2606 | * |
* | White, non-Hispanic | Male | Insured | 0.8633 | 0.8278 | 0.8924 | |
* | Black, non-Hispanic | Male | Insured | 0.7073 | 0.6456 | 0.7622 | |
* | Hispanic | Male | Insured | 0.6344 | 0.5786 | 0.6867 | |
* | Asian/PI, non-Hispanic | Male | Insured | 0.8564 | 0.7845 | 0.9072 | |
* | Other,non-Hispanic | Male | Insured | 0.7702 | 0.5347 | 0.9072 | * |
* | White, non-Hispanic | Female | Insured | 0.9139 | 0.8844 | 0.9365 | |
* | Black, non-Hispanic | Female | Insured | 0.8039 | 0.7590 | 0.8421 | |
* | Hispanic | Female | Insured | 0.7621 | 0.7201 | 0.7996 | |
* | Asian/PI, non-Hispanic | Female | Insured | 0.8955 | 0.8324 | 0.9366 | |
* | Other,non-Hispanic | Female | Insured | 0.8602 | 0.7394 | 0.9303 |
PROC REPORT output
-2 | -2 | 0.1956 | 0.1804 | 0.2117 | 0.8044 | 0.7883 | 0.8196 | ||
White, non-Hispanic | 0.1118 | 0.0926 | 0.1343 | 0.8882 | 0.8657 | 0.9074 | |||
Black, non-Hispanic | 0.2389 | 0.2057 | 0.2755 | 0.7611 | 0.7245 | 0.7943 | |||
Hispanic | 0.2944 | 0.2627 | 0.3282 | 0.7056 | 0.6718 | 0.7373 | |||
Asian/PI, non-Hispanic | 0.1250 | 0.0896 | 0.1716 | 0.8750 | 0.8284 | 0.9104 | |||
Other,non-Hispanic | 0.1550 | 0.0788 | 0.2824 | * | 0.8450 | 0.7176 | 0.9212 | * | |
Male | -2 | 0.2328 | 0.2087 | 0.2587 | 0.7672 | 0.7413 | 0.7913 | ||
White, non-Hispanic | 0.1367 | 0.1076 | 0.1722 | 0.8633 | 0.8278 | 0.8924 | |||
Black, non-Hispanic | 0.2927 | 0.2378 | 0.3544 | 0.7073 | 0.6456 | 0.7622 | |||
Hispanic | 0.3656 | 0.3133 | 0.4214 | 0.6344 | 0.5786 | 0.6867 | |||
Asian/PI, non-Hispanic | 0.1436 | 0.0928 | 0.2155 | 0.8564 | 0.7845 | 0.9072 | |||
Other,non-Hispanic | 0.2298 | 0.0928 | 0.4653 | * | 0.7702 | 0.5347 | 0.9072 | * | |
Female | -2 | 0.1618 | 0.1432 | 0.1823 | 0.8382 | 0.8177 | 0.8568 | ||
White, non-Hispanic | 0.0861 | 0.0635 | 0.1156 | 0.9139 | 0.8844 | 0.9365 | |||
Black, non-Hispanic | 0.1961 | 0.1579 | 0.2410 | 0.8039 | 0.7590 | 0.8421 | |||
Hispanic | 0.2379 | 0.2004 | 0.2799 | 0.7621 | 0.7201 | 0.7996 | |||
Asian/PI, non-Hispanic | 0.1045 | 0.0634 | 0.1676 | 0.8955 | 0.8324 | 0.9366 | |||
Other,non-Hispanic | 0.1398 | 0.0697 | 0.2606 | * | 0.8602 | 0.7394 | 0.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!
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.)
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
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
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.