After data analysis, I have created a table like below. I was asked to calculate weighted proportion, weighted sensitivity, and weighted specificity of each type. I googled a lot but no success. Please help. If not possible in SAS, is there any way to calculate manually, at lease.
Type | Count_TotalPop | Count_SurveyPop | Sensitivity | Specificity | Proportion_TotalPop | Proportion_SurveyPop |
A | 4000 | 20 | 79 | 67 | 0.23 | 0.17 |
B | 3500 | 30 | 100 | 69 | 0.20 | 0.26 |
C | 3000 | 25 | 90 | 78 | 0.17 | 0.21 |
D | 2000 | 20 | 100 | 100 | 0.11 | 0.17 |
E | 5000 | 22 | 75 | 55 | 0.29 | 0.19 |
I am not sure I understand what you mean when you ask "weight of which variable?" Typically the weight is part of the sample design. I would suggest going back to the person who asked for the weighted statistics and ask them what they want you to weight the analysis by.
As far as an example you could look at the Getting Started example in the SURVEYFREQ statement. Note how the data has a variable in it called SamplingWeight which was part of the design.
SAS Help Center: Getting Started: SURVEYFREQ Procedure
In your case since you only have weights and not a complex survey design, you would remove the CLUSTER and STRATA statements.
proc surveyfreq data=SIS_Survey;
tables SchoolType * Response / senspec;
weight SamplingWeight;
run;
calling @StatDave
data have;
set sashelp.heart;
keep status bp_status sex;
run;
proc freq data=have noprint;
table bp_status*status*sex/out=temp list;
run;
proc freq data=temp;
by bp_status;
table status*sex/senspec ;
weight COUNT;
run;
One easy way to do this would be to use Proc SURVEYFREQ with the WEIGHT statement and the SENSPEC option on the TABLES statement.
I am not sure I understand what you mean when you ask "weight of which variable?" Typically the weight is part of the sample design. I would suggest going back to the person who asked for the weighted statistics and ask them what they want you to weight the analysis by.
As far as an example you could look at the Getting Started example in the SURVEYFREQ statement. Note how the data has a variable in it called SamplingWeight which was part of the design.
SAS Help Center: Getting Started: SURVEYFREQ Procedure
In your case since you only have weights and not a complex survey design, you would remove the CLUSTER and STRATA statements.
proc surveyfreq data=SIS_Survey;
tables SchoolType * Response / senspec;
weight SamplingWeight;
run;
Weighted how? What weight is to be applied where?
@Barkat wrote:
After data analysis, I have created a table like below. I was asked to calculate weighted proportion, weighted sensitivity, and weighted specificity of each type. I googled a lot but no success. Please help. If not possible in SAS, is there any way to calculate manually, at lease.
Type Count_TotalPop Count_SurveyPop Sensitivity Specificity Proportion_TotalPop Proportion_SurveyPop A 4000 20 79 67 0.23 0.17 B 3500 30 100 69 0.20 0.26 C 3000 25 90 78 0.17 0.21 D 2000 20 100 100 0.11 0.17 E 5000 22 75 55 0.29 0.19
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.