DATA Step, Macro, Functions and more

How to Use Regression to Fill missing Values like

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 7
Accepted Solution

How to Use Regression to Fill missing Values like

[ Edited ]

How to Use Regression to Fill missing Values like this Examlpe 

I have alot of missing values 

but i don't want to replace it with static Value,as we can change the missing with mean and Standard Deviasion then i want to predict the Missing Value using an algorithm like Regression 

 

simply i want to Merge First and Second code 

 

data yourdata;

   set yourdata;

   array change _numeric_;

            do over change;

            if change=OldValue  then change=newValue

            end;

   run ;


Proc reg data=yourdata

Model=

Run 

 

want to use the second Code replace the newValue


Accepted Solutions
Solution
‎06-02-2016 05:35 AM
Super User
Posts: 19,878

Re: How to Use Regression to Fill missing Values like

If you want to interpolate using regression you can use proc reg and get the output with the predicted value.

Here's an example using the CLASS dataset.

 

data class;
set sashelp.class;
if weight in (84, 112) then weight = .;
run;

proc reg data=class;
model weight = height age;
output out=want predicted=p;
run;quit;

proc print data=want;
run;

 

View solution in original post


All Replies
Super User
Posts: 19,878

Re: How to Use Regression to Fill missing Values like

I don't understand what your question is, please clarify. If you can post sample data and expected output. 

Occasional Contributor
Posts: 7

Re: How to Use Regression to Fill missing Values like

[ Edited ]

I have alot of missing values 

but i don't want to replace it with static Value,as we can change the missing with mean and Standard Deviasion then i want to predict the Missing Value using an algorithm like Regression 

Respected Advisor
Posts: 4,937

Re: How to Use Regression to Fill missing Values like

Don't change a missing value with zero unless zero truly is the observed value. A missing value signals the absence of information and is treated appropriatly.  

 

Note: // is not the syntax for comments in SAS code.

PG
Occasional Contributor
Posts: 7

Re: How to Use Regression to Fill missing Values like

I would like to predict this missing value, How to do that ?

 

Thanks for your replan ....

Solution
‎06-02-2016 05:35 AM
Super User
Posts: 19,878

Re: How to Use Regression to Fill missing Values like

If you want to interpolate using regression you can use proc reg and get the output with the predicted value.

Here's an example using the CLASS dataset.

 

data class;
set sashelp.class;
if weight in (84, 112) then weight = .;
run;

proc reg data=class;
model weight = height age;
output out=want predicted=p;
run;quit;

proc print data=want;
run;

 

☑ This topic is solved.

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

Discussion stats
  • 5 replies
  • 305 views
  • 1 like
  • 3 in conversation