Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- Assigning constant values from observations

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-17-2008 09:13 PM

Hi,

I have a data set containing coefficients for a regression equation (single observation with variables representing each coefficient). I would like to use the coefficients to generate predicted values in another data set of N observations. Would I be able to assign the coefficients as "constant" variables for use in the N observation data set?

Coefficients Data Set: Var1 ... Var9

N Observations Data Set: VarA ... VarX

VarA ... VarX

VarA ... VarX

Predicted = Var1 + Var2*VarA + Var9*VarX

I have a data set containing coefficients for a regression equation (single observation with variables representing each coefficient). I would like to use the coefficients to generate predicted values in another data set of N observations. Would I be able to assign the coefficients as "constant" variables for use in the N observation data set?

Coefficients Data Set: Var1 ... Var9

N Observations Data Set: VarA ... VarX

VarA ... VarX

VarA ... VarX

Predicted = Var1 + Var2*VarA + Var9*VarX

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to deleted_user

03-17-2008 10:46 PM

Think about this. As the SET statement is executable, you could read the coefficients, retain them for th DATA step, and then drop the variables from the output dataset; this is done once. You could have a second SET statement to read in the nObs dataset.

* untested code;

DATA scored;

IF _N_=1 then SET Coefficients;

RETAIN Var1-Var9;

DROP Var1-Var9;

SET NObs;

Predicted = Var1 + Var2*VarA + Var9*VarX ;

RUN;

* untested code;

DATA scored;

IF _N_=1 then SET Coefficients;

RETAIN Var1-Var9;

DROP Var1-Var9;

SET NObs;

Predicted = Var1 + Var2*VarA + Var9*VarX ;

RUN;