PLEASE Test your data step before posting. The variable type is wrong for Table and Value_labels, your value labels includes the delimiter so you need to quote the values.
data have;
infile datalines dsd dlm=',' truncover;
input TM_group ADRD_group Table:$20. Value_Labels :$20. WgtFreq Percent;
TM_Adrd_group = cats(tm_group,adrd_group);
datalines;
0,0,Table DEM_AGE,"2:Age Group [65,75)",48301097,56.0249
0,0,Table DEM_AGE,3:Age Group >=75,37912485,43.9751
0,0,Table DEM_SEX,1:Male,36957033,42.8668
0,0,Table DEM_SEX,2:Female,49256549,57.1332
0,1,Table DEM_AGE,"2:Age Group [65,75)",983069,26.8767
0,1,Table DEM_AGE,3:Age Group >=75,2674626,73.1233
0,1,Table DEM_SEX,1:Male,1363336,37.2731
0,1,Table DEM_SEX,2:Female,2294360,62.7269
1,0,Table DEM_AGE,"2:Age Group [65,75)",82517247,60.1757
1,0,Table DEM_AGE,3:Age Group >=75,54609890,39.8243
1,0,Table DEM_SEX,1:Male,63773136,46.5066
1,0,Table DEM_SEX,2:Female,73354000,53.4934
1,1,Table DEM_AGE,"2:Age Group [65,75)",1290895,25.8295
1,1,Table DEM_AGE,3:Age Group >=75,3706852,74.1705
1,1,Table DEM_SEX,1:Male,2215172,44.3234
1,1,Table DEM_SEX,2:Female,2782576,55.6766
; RUN;
proc format library=work;
value $tm_adrd
'00'='no TM, no ADRD'
'01'='no TM, ADRD'
'10'='TM, no ADRD'
'11'='TM, ADRD'
;
run;
proc report data=have;
columns table value_labels tm_adrd_group,(WgtFreq Percent);
define table/group;
define value_labels/group;
define tm_adrd_group /across format=$tm_adrd. order=internal;
run;
Though I would create the group variable, or others prior to summary then generate the summary with that new variable so there aren't any questions about combining stuff. If you are doing confidence limits this would be required.
You show
no TM, no ADRD
no TM, ADRD
TM, no ADRD
TM, ADRD
without a clear definition of where those come from.
I have to guess that means the combinations of the variables Tm_group and Adrd_group.
One approach would be to create a composite variable in a data step such as
TM_Adrd_group = cats(tm_group,adrd_group);
Which should create a character variable with values of '00', '01','10' and '11'.
create format to show such things as "no TM, no ADRD" for the '00' version.
Then in one of the reporting procedures assign that format to the composite variable.
Either Proc Report or Tabulate would do such nesting the WgtFreq and Percent under the Tm_adrd_group
... View more