Hello, I'm trying to format a table in a report I am programing. I'm having some issues that I haven't been able to work through on my own, and I was wondering if there even is a way to do what I'm trying to do! Below are some sample data and my current PROC TABULATE step. data table1;
input sn q1n q2n arm age_cat patient_gender patient_pcp; label sn = "Screened" q1n = "Eligible" q2n = "Consented" age_cat = "Age" patient_pcp = "Has Primary Care Physician" patient_gender = "Gender Identity" ;
CARDS;
1 1 1 1 1 1 1
1 1 1 1 1 1 1
1 1 1 1 2 1 1
1 1 1 1 2 1 1
1 1 1 1 2 2 1
1 1 1 1 2 2 1
1 1 1 1 3 2 1
1 1 1 1 3 2 1
1 1 1 1 3 2 2
1 1 1 1 4 2 2
1 0 0 1 0 0 0
1 0 0 1 0 0 0
1 0 0 1 0 0 0
1 0 0 1 0 0 0
1 0 0 1 0 0 0
1 0 0 1 0 0 0
1 0 0 1 0 0 0
1 0 0 1 0 0 0
1 0 0 1 0 0 0
1 0 0 1 0 0 0
;
run;
data class3;
input arm age_cat patient_gender patient_pcp; label age_cat = "Age" patient_pcp = "Has Primary Care Physician" patient_gender = "Gender Identity" ;
CARDS;
1 1 1 1
1 1 1 2
1 1 1 3
1 1 2 1
1 1 2 2
1 1 2 3
1 1 3 1
1 1 3 2
1 1 3 3
1 1 4 1
1 1 4 2
1 1 4 3
1 1 5 1
1 1 5 2
1 1 5 3
1 2 1 1
1 2 1 2
1 2 1 3
1 2 2 1
1 2 2 2
1 2 2 3
1 2 3 1
1 2 3 2
1 2 3 3
1 2 4 1
1 2 4 2
1 2 4 3
1 2 5 1
1 2 5 2
1 2 5 3
1 3 1 1
1 3 1 2
1 3 1 3
1 3 2 1
1 3 2 2
1 3 2 3
1 3 3 1
1 3 3 2
1 3 3 3
1 3 4 1
1 3 4 2
1 3 4 3
1 3 5 1
1 3 5 2
1 3 5 3
1 4 1 1
1 4 1 2
1 4 1 3
1 4 2 1
1 4 2 2
1 4 2 3
1 4 3 1
1 4 3 2
1 4 3 3
1 4 4 1
1 4 4 2
1 4 4 3
1 4 5 1
1 4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value agefmt 1 = "18-29"
2 = "30-39"
3 = "40-49"
4 = "50-59"
5 = "60-69"
6 = ">=70";
value genderfmt 1 = "Man"
2 = "Woman"
3 = "Non-binary/non-conforming"
4 = "Other"
5 = "Decline";
value pcpfmt 1 = "Yes"
2 = "No"
3 = "Decline";
run;
proc tabulate data = table1 classdata = class3 order=data format=20. style={bordercolor=black background=white borderwidth=1 cellwidth=80 font=("Times New Roman", 7pt,Normal)};
class arm age_cat patient_gender patient_pcp/preloadfmt ORDER=DATA s={bordercolor=black background=white borderwidth=1 cellwidth=200 font=("Times New Roman", 7pt,Bold) just=c} ;
classlev arm age_cat patient_gender patient_pcp/ s={bordercolor=black background=white borderwidth=1 cellwidth=200 font=("Times New Roman", 7pt,Bold)};
var sn q1n q2n/ s={bordercolor=black background=white borderwidth=1 font=("Times New Roman", 7pt,Bold)};
table sn (q1n)*(sum*f=best12. colpctsum<sn>*f=pctf.) (q2n)*(sum*f=best12. colpctsum<q1n>*f=pctf.) (age_cat)*(n*f=best12. colpctn<q2n>*f=pctf.) (patient_gender)*(n*f=best12. colpctn<q2n>*f=pctf.) (patient_pcp)*(n*f=best12. colpctn<q2n>*f=pctf.), arm ALL='Total' /printmiss box={s={bordercolor=black background=white borderwidth=1}};
format arm armfmt. age_cat agefmt. patient_gender genderfmt. patient_pcp pcpfmt.;
keyword all sum colpctsum colpctn n/ s={background=white font=("Times New Roman", 7pt,Bold)};
keylabel n ='N' sum='N' colpctsum = '%' colpctn = '%';
label arm = 'Arm';
title j=left font = "Times New Roman" 'Table 1: Patient Screening & Demographic Information';
run; The outputted table looks like this: This is close to what I want, but I would like to remove the '0' rows which represent missing. I tried setting these values to missing, but the table would then only include those who were consented i.e. remove observations from the table that had missing values and make the screened value incorrect. I also would like to add formatting to the box directly to the right of the variable labels. It is currently outputting shaded blue, and I would like to remove that to match the formatting on the rest of the table. Any guidance would be appreciated, thank you!
... View more