Programming the statistical procedures from SAS

Impute missing values of the vairables with median by study, treatment and gender

Reply
Frequent Contributor
Frequent Contributor
Posts: 101

Impute missing values of the vairables with median by study, treatment and gender

 Hi All,

 

I am trying impute the missing values for the vairables in a dataset with median by study, treatment and gender using proc stdize.

 

proc stdize data=have out=want missing=median reponly;
var   alti albi asti;
by study notsorted treatment notsorted gender notsorted;
run;

 

But this code gives the following error:

 

WARNING: At least one of the scale and location estimators of variable alti can not be
computed. Variable alti will not be standardized.

 

Please let me know how to resolve this issue.

 

Thanks

Super Contributor
Posts: 483

Re: Impute missing values of the vairables with median by study, treatment and gender

[ Edited ]

When you use the REPONLY option, PROC STDIZE does not standardize the data, but merely replaces the missing values with the values you specify in your MISSING= option.

 

This is specified in the syntax documentation for PROC STDIZE here

 

https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_stdize_sect...

Frequent Contributor
Frequent Contributor
Posts: 101

Re: Impute missing values of the vairables with median by study, treatment and gender

@draycut: Yes, that is what I wanted I just need to replace the missing values. 

Super Contributor
Posts: 483

Re: Impute missing values of the vairables with median by study, treatment and gender

[ Edited ]

Ah ok, I missread, I thought you actually wanted to standardize your data Smiley Happy

SAS Super FREQ
Posts: 3,317

Re: Impute missing values of the vairables with median by study, treatment and gender

This could indicate that the ALTI variable does not have a sufficient number of nonzero statistics for one of the BY groups. Change to PROC MEANS and write the mediians to a data set, like in this example (untested):

 

proc means data=have median noprint;
var   alti albi asti;
by study notsorted treatment notsorted gender notsorted;
output out=out median=;
run;

proc print data=out;
where alti=.;
run;
Frequent Contributor
Frequent Contributor
Posts: 101

Re: Impute missing values of the vairables with median by study, treatment and gender

[ Edited ]

@Rick_SAS:

 

Hi Rick, Thanks for this solution, this is the output from the table. I'm  still not sure how to use this table. 

 

                                                        study    treatment gender _TYPE_  _FREQ_ alti        asti        albi 

2013106...
2012109.43.572
20111033..72

 
Frequent Contributor
Frequent Contributor
Posts: 101

Re: Impute missing values of the vairables with median by study, treatment and gender

[ Edited ]
SAS Super FREQ
Posts: 3,317

Re: Impute missing values of the vairables with median by study, treatment and gender

You "use it" by recognizing what it means. There are three BY groups for which the median is missing. Use a WHERE clause to exclude those BY groups. For example:

 

WHERE stud ^= 201;

Grand Advisor
Posts: 9,463

Re: Impute missing values of the vairables with median by study, treatment and gender

Why you add NOTSORTED ? it is keyword for BY statement, 

I think you should remove it.

 

by study notsorted treatment notsorted gender notsorted;

-->

by study  treatment  gender;

Grand Advisor
Posts: 16,916

Re: Impute missing values of the vairables with median by study, treatment and gender

I agree with @Ksharp

Likeky using the NOTSORTED option is causing an incorrect calculation of the median for your groups. 

Ask a Question
Discussion stats
  • 9 replies
  • 162 views
  • 1 like
  • 5 in conversation