I like to replace some values of a continuous variable to missing by random. I wonder what is the code in SAS for this.
Also Like to know if I can do multiple imputation for variable with whole missing values based on other variables in the data set. If so I wonder what is SAS codes for this as well.
Thanks
@mmovahed wrote:
I like to replace some values of a continuous variable to missing by random. I wonder what is the code in SAS for this.
Seems like an odd thing to do.
data want;
set have;
random=rand('uniform');
if random<0.2 then x=.;
run;
Also Like to know if I can do multiple imputation for variable with whole missing values based on other variables in the data set. If so I wonder what is SAS codes for this as well.
Look at the examples in the documentation for PROC MI.
Thanks. It was useful.
The answer depends on whether you want to replace a variable with a missing value:
A program for #1 will be quite different (and more complex - there're different algorithms for doing it) than for #2 at which @PaigeMiller has hinted.
And also it depends on whether every time you run the code you want to:
and possibly a number of other factors.
Kind regards
Paul D.
@mmovahed wrote:
Also Like to know if I can do multiple imputation for variable with whole missing values based on other variables in the data set. If so I wonder what is SAS codes for this as well.
You may need to describe exactly what you mean by "whole missing values ". That sort of sounds like you have no actual values for a variable. Without at least a few values it is going to be real hard to determine any sort of rule that uses other variables to impute.
If you have a categorical variable that should have 4 levels but one of the levels doesn't appear, for example, then what rule would be used to determine the missing should be the category with no representation?
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.