Hi all,
Please let me know how to proceed if I want to include the missing value in the calculation variables (ED ICU Regular Physician Lab Radiology Pharma Thera).
proc tabulate data=have out=want;
var ED ICU Regular Physician Lab Radiology Pharma Thera;
class PT_class;
table (ED ICU Regular Physician Lab Radiology Pharma Thera), (PT_class all)*((N mean median p25 p75 sum));
format PT_class PT_class.;
run;
To include missing values in the calculation variables in proc tabulate, you can use the MISSING
option in the VAR
statement. This will tell proc tabulate to include missing values in the calculations for the specified variables. Here is an example of how to do this:
proc tabulate data=have out=want;
var ED ICU Regular Physician Lab Radiology Pharma Thera / missing;
class PT_class;
table (ED ICU Regular Physician Lab Radiology Pharma Thera), (PT_class all)*((N mean median p25 p75 sum));
format PT_class PT_class.;
run;
Note that using the MISSING
option will include missing values in the calculations for all of the specified variables, not just for individual variables.
Do you mean missing values of PT_CLASS?
You can add the MISSING option to the PROC TABULATE statement.
How do you want the "missing values" for the Var variables included? You can get a count of the missing values using the NMISS statistic.
proc tabulate data=have out=want;
var ED ICU Regular Physician Lab Radiology Pharma Thera;
class PT_class;
table (ED ICU Regular Physician Lab Radiology Pharma Thera), (PT_class all)*((N mean median p25 p75 sum nmiss));
format PT_class PT_class.;
run;
I have missing values in all the variables to be calculated. To get the average of them, I would like to include the count of the missing values in the denominator. Maybe I should use another step to do this separately cause the code is used to count all the non-missing values. Right?
@ybz12003 wrote:
I have missing values in all the variables to be calculated. To get the average of them, I would like to include the count of the missing values in the denominator. Maybe I should use another step to do this separately cause the code is used to count all the non-missing values. Right?
Do you mean you want to treat missing values as 0? So this will lower all your statistics? If that's what you want, I would probably use a data step to replace missing values with 0. But it would be an unusual approach to treat missing values as 0.
To include missing values in the calculation variables in proc tabulate, you can use the MISSING
option in the VAR
statement. This will tell proc tabulate to include missing values in the calculations for the specified variables. Here is an example of how to do this:
proc tabulate data=have out=want;
var ED ICU Regular Physician Lab Radiology Pharma Thera / missing;
class PT_class;
table (ED ICU Regular Physician Lab Radiology Pharma Thera), (PT_class all)*((N mean median p25 p75 sum));
format PT_class PT_class.;
run;
Note that using the MISSING
option will include missing values in the calculations for all of the specified variables, not just for individual variables.
I don't see a /missing option for the VAR statement in the documentation. And when I run in 9.4, I get an error:
1
2 data class ;
3 set sashelp.class ;
4 if _n_=1 then age=. ;
5 run ;
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.CLASS has 19 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 559.21k
OS Memory 16624.00k
Timestamp 12/07/2022 03:35:00 PM
Step Count 13 Switch Count 0
6
7 proc tabulate data=class ;
8 class sex ;
9 var age /missing;
-------
22
202
ERROR 22-322: Syntax error, expecting one of the following: ;, STYLE, WEIGHT, WGT.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
10 tables sex,age*(n nmiss mean median) ;
11 run ;
Is that accepted answer working? In what version of SAS does it work?
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.