BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kz_
Quartz | Level 8 kz_
Quartz | Level 8

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;
1 ACCEPTED SOLUTION

Accepted Solutions
sbxkoenk
SAS Super FREQ

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 :

MISSING=method | value

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

View solution in original post

9 REPLIES 9
sbxkoenk
SAS Super FREQ

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_
Quartz | Level 8 kz_
Quartz | Level 8
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.
PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller
PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller
Ksharp
Super User
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;
Tom
Super User Tom
Super User

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=.

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.3/statug/statug_stdize_syntax01.htm#statug.stdi...

 

Tom
Super User Tom
Super User

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;
sbxkoenk
SAS Super FREQ

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 :

MISSING=method | value

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

ballardw
Super User

 

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;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 9 replies
  • 1970 views
  • 1 like
  • 6 in conversation