Programming the statistical procedures from SAS

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

Accepted Solution Solved
Reply
Frequent Contributor
Frequent Contributor
Posts: 105
Accepted Solution

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


Accepted Solutions
Solution
Tuesday
Super User
Posts: 20,765

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. 

View solution in original post


All Replies
PROC Star
Posts: 977

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: 105

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. 

PROC Star
Posts: 977

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,841

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: 105

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: 105

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

[ Edited ]
SAS Super FREQ
Posts: 3,841

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;

Super User
Posts: 10,217

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;

Solution
Tuesday
Super User
Posts: 20,765

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. 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 9 replies
  • 701 views
  • 1 like
  • 5 in conversation