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

I am handling a cross-sectional data set.

I identified that a number of my variable of interests were missing values, including continued, bi-variate and ordinal data. 

I am wondering if I can replace the missing values by its mean or median.     

And I want to know if there is a cap for allowing the replacing its value, e.g., missing values must less than 10% or so.  

 

Anyone can help much appreciated.

 

Phan S.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Here's an inefficient macro that will cap the outliers. 

https://gist.github.com/statgeek/31316a678433a1db8136

 

PROC STDIZE is a better option for replacing with median/mean. You can also look into PROC MI, multiple imputation to impute missing data. 

 

View solution in original post

5 REPLIES 5
stat_sas
Ammonite | Level 13

Hi,

 

Missing values can be replaced with various statistics using proc stdize. Below is an example replacing missing values with median.

Defining a cap would be based on your analysis. You can flag variables containing a certain percentage of missing values for imputation.

 

 

 

proc stdize data=have reponly method=median out=imputed;
var a b c; /* Assuming a, b and c are 3 numeric variables */
run;

PhanS
Obsidian | Level 7

Hello,

 

I am sorry, I mean I give the solution (credit) to you, bu accidentally check to Reeza. 

 

Thank you for you code.

 

Phan S. 

 

Reeza
Super User

@PhanS You can change that to @stat_sas, just select theirs instead.

stat_sas
Ammonite | Level 13

Hi,

 

I am glad you have the solution. I am also  learning from @Reeza's posts Smiley Happy

 

Reeza
Super User

Here's an inefficient macro that will cap the outliers. 

https://gist.github.com/statgeek/31316a678433a1db8136

 

PROC STDIZE is a better option for replacing with median/mean. You can also look into PROC MI, multiple imputation to impute missing data. 

 

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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
  • 5 replies
  • 1858 views
  • 0 likes
  • 3 in conversation