Does anyone see an obvious reason why this doesn't work? There are no errors or warnings in the log, but none of the missing values are being imputed. Is there any easier way to impute them?
proc sort data=msrp; by use model_name; run; proc stdize data=msrp out=msrp2 reponly method=mean; by use model_name; var msrp; run;
Hello @Tom ,
Giving feedback on your 2 posts above.
Method= option should be sufficient to replace missings with REPONLY. You do not need missing= option.
From the doc :
specifies the method (or a numeric value) for replacing missing values. If you omit the MISSING= option, the REPLACE option replaces missing values with the location measure given by the METHOD= option. Specify the MISSING= option when you want to replace missing values with a different value. You can specify any name that is valid in the METHOD= option except the name IN. The corresponding location measure is used to replace missing values.
If a numeric value is given, the value replaces missing values after standardizing the data. However, you can specify the REPONLY option with the MISSING= option to suppress standardization for cases in which you want only to replace missing values.
Secondly ,
@kz_ claims he / she did already check for missing values. Each by-group seems to have valid values he / she says.
Thanks,
Koen
Hello,
I do not see an obvious error in your code / syntax.
Maybe you are having by-groups with only missing values. In that case, no location measure can be calculated.
Koen
@kz_ wrote:
I already checked and that is not the case, so I can calculate the mean of the by groups and 'manually' impute, but that seems like a pain.
Show us your data. Show us what you see. Simply stating it isn't working will not ever be enough for us to help you solve the problem.
@kz_ wrote:
Does anyone see an obvious reason why this doesn't work? There are no errors or warnings in the log, but none of the missing values are being imputed. Is there any easier way to impute them?
proc sort data=msrp; by use model_name; run; proc stdize data=msrp out=msrp2 reponly method=mean; by use model_name; var msrp; run;
It is my experience that PROC STDIZE does replace missing values. So you need to show us (a portion of) the data you are using, and the output where it appears the missings are not replaced.
data heart;
set sashelp.heart;
call streaminit(1);
if rand('bern',0.4) then call missing(height,weight);
proc sort data=heart;
by sex;
run;
proc stdize data=heart out=msrp2 reponly missing=mean;
by sex;
var weight height;
run;
Did you tell it to replace missing values?
You told it NOT to standardize by using REPONLY. But then did not tell it to replace the missing values by using MISSING=.
It cannot replace the missing with the MEAN if there are no non-missing values.
Example:
data class;
set sashelp.class ;
if sex='M' then height=.;
if name=:'A' then weight=.;
run;
proc sort;
by sex name;
run;
proc stdize data=class out=class1 reponly method=mean;
by sex;
var height weight;
run;
proc compare data=class compare=class1;
id sex name;
run;
Hello @Tom ,
Giving feedback on your 2 posts above.
Method= option should be sufficient to replace missings with REPONLY. You do not need missing= option.
From the doc :
specifies the method (or a numeric value) for replacing missing values. If you omit the MISSING= option, the REPLACE option replaces missing values with the location measure given by the METHOD= option. Specify the MISSING= option when you want to replace missing values with a different value. You can specify any name that is valid in the METHOD= option except the name IN. The corresponding location measure is used to replace missing values.
If a numeric value is given, the value replaces missing values after standardizing the data. However, you can specify the REPONLY option with the MISSING= option to suppress standardization for cases in which you want only to replace missing values.
Secondly ,
@kz_ claims he / she did already check for missing values. Each by-group seems to have valid values he / she says.
Thanks,
Koen
If you have some levels of the variable Model_name without any values for specific Use variable values then the location measure does not exist for that by group. So there is nothing to use for imputing within that by group.
You can check for that condition with
Proc freq data=msrp; tables use*model_name / list missing; run;
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 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: