@ballardw I will attempt to explain again.
The dataset above - WORK.SAS_COMMUNITIES - has 82 observations. This is a subset of the overall dataset. That number - 82 - is being used as the "n" and as the denominator for calculating Percent (of Respondents) in the last column of the attached PROC TABULATE output/table (See below). I want the "n" and the denominator to be the number of respondents who have answered the question, not the number of observations in the dataset.
You are correct, record_id=2, 17, 18, 23, 38, 41, 61, 85, and 86 exhibit "the same behavior" (i.e. A value of "0" in provider_type1-provider_type14 when the question has NOT been answered.). 82 - 9 = 73. I don't know how to calculate this in SAS, so I am doing it manually. I hope I identified the correct number, 9.
73 out of 82 respondents answered this question, according to the WORK.SAS_COMMUNITIES dataset. Therefore, 73, in this example, is the "n" and the denominator I am seeking.
This is the syntax I am using:
PROC TABULATE DATA=WORK.SAS_COMMUNITIES ORDER=formatted;
VAR provider_type___1-provider_type___14 record_id;
TABLE provider_type___1 - provider_type___14 ,
(n='n'*f=7. Sum='Count'*f=7. mean='Percent'*f=percent8.1);
LABEL
provider_type___1 = "Medical Doctor (i.e. MD)"
provider_type___2 = "Osteopathic Doctor (i.e. DO)"
provider_type___3 = "Naturopathic Doctor (i.e. ND)"
provider_type___4 = "Physicians Assistant (i.e. PA)"
provider_type___5 = "Nurse Practitioner (i.e. NP)"
provider_type___6 = "Registered Nurse (i.e. RN)"
provider_type___7 = "Pharmacist (i.e. Rph)"
provider_type___8 = "Massage therapist (i.e. LMP)"
provider_type___9 = "Acupuncturist (i.e. LAc)"
provider_type___10 = "Chiropractor (i.e. DC)"
provider_type___11 = "Clinical social worker (i.e. LCSW)"
provider_type___12 = "Physical therapist (i.e. PT)"
provider_type___13 = "Psychiatrist"
provider_type___14 = "Other";
TITLE "What type of licensed healthcare provider are you?";
RUN;
*-----------------------------------------------;
* PROVIDER TYPE - LICENSED - SORTED;
*-----------------------------------------------;
DATA data_working_keep;
KEEP record_id provider_type___1-provider_type___14;
SET WORK.SAS_COMMUNITIES;
LABEL
provider_type___1 = "Medical Doctor (i.e. MD)"
provider_type___2 = "Osteopathic Doctor (i.e. DO)"
provider_type___3 = "Naturopathic Doctor (i.e. ND)"
provider_type___4 = "Physicians Assistant (i.e. PA)"
provider_type___5 = "Nurse Practitioner (i.e. NP)"
provider_type___6 = "Registered Nurse (i.e. RN)"
provider_type___7 = "Pharmacist (i.e. Rph)"
provider_type___8 = "Massage therapist (i.e. LMP)"
provider_type___9 = "Acupuncturist (i.e. LAc)"
provider_type___10 = "Chiropractor (i.e. DC)"
provider_type___11 = "Clinical social worker (i.e. LCSW)"
provider_type___12 = "Physical therapist (i.e. PT)"
provider_type___13 = "Psychiatrist"
provider_type___14 = "Other";
RUN;
proc sort data=data_working_keep;
by record_id;
run;
Proc transpose data=data_working_keep
out=trans_mchps;
by record_id;
run;
*proc tabulate data=trans_mchps;
*where col1=1;
*class _label_ /order=freq;
*label _label_='Response';
*table _label_ all='Total',
n='n'*f=best6. colpctn='%'
/
;
*run;
proc summary data=trans_mchps;
class _label_;
var col1;
output out=transsum n= sum=/autoname;
run;
proc sort data=transsum;
by descending _type_ descending col1_sum ;
run;
data display;
set transsum;
if missing(_label_) then do;
_label_ ='Total';
percent= 999;
end;
else percent = 10.*(col1_sum/col1_n);
run;
proc print data=display noobs label;
var _label_;
var col1_sum / style(data)={just=c};
var percent / style(data)={just=c};
label _label_='Response'
col1_sum='Number selected'
percent='Percent of Respondents'
;
format col1_sum best6. percent f5.1;
TITLE "What type of licensed healthcare provider are you?";
TITLE2 "NOTE: This is a multiple response variable (i.e. Check all that apply) so the column does not sum to 100%";
TITLE3 "Percent of RESPONDENTS, not responses ";
TITLE4 "n = TBD";
run;
The "n" in the first table (Unsorted) is 82. I would like it to be 73. Same for the second table (Sorted).
I understand if you are frustrated. Please know that you are no more frustrated than I. Trying to decipher suggested syntax and interpret the SAS vernacular used in many of the responses to my posts are both very challenging. I am not a SAS expert.
Thanks for your time and assistance.
... View more