BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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
1 REPLY 1
Doc_Duke
Rhodochrosite | Level 12
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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 764 views
  • 0 likes
  • 2 in conversation