title '6b. Mixing Categorical and Continuous Data Percentages'; * For numeric variables, create categories to label and group values; proc format; value agec 1='Age (Years)'; value sexc 1='Sex'; value wgtc 1='Weight'; value agefmt 1='0 - 15' 2='16 - 64' 3='>= 65'; value sexfmt 1='Male' 2='Female'; value wgtfmt 1='<= 100' 2='> 100'; run; data class; * Create dummy variables; agecol=1; racecol=1; sexcol=1; wgtcol=1; set sashelp.class; * Apply numeric grouping; if 0 le age le 15 then agecat=1; else if 16 le age le 64 then agecat=2; else if age ge 65 then agecat=3; * Apply to label Sex as Male and Female instead of M and F; if sex='M' then sexcat=1; else if sex='F' then sexcat=2; * Apply numeric grouping; if weight <= 100 then wgtcat=1; else if weight > 100 then wgtcat=2; run; proc tabulate data=class missing; class agecol sexcol wgtcol agecat sexcat wgtcat; format agecat agefmt. sexcat sexfmt. agecol agec. sexcol sexc. wgtcat wgtfmt. wgtcol wgtc.; keylabel N='N' PCTN='%'; * Age and weight groups are rows by sex values as columns; tables (agecol=' '*agecat=' ' wgtcol=' '*wgtcat=' ') , (sexcol=' '*sexcat=' ' all)*(n='N' pctn='%'); * Altenative to PCTN<>; *tables (agecol=' '*agecat=' ' wgtcol=' '*wgtcat=' ') , (sexcol=' '*sexcat=' ' all)*(n='N' colpctn='%'); run;