Hello I have two data sets.
One data set is
par EST t
Inter 123 7
HW 212 16
WW 78 5
My second data set is
FAMINC HW WW
122 143 897
432 987 645
212 789 656
132 123 112
In second data set i need a new variable p = value of inter from table1(which is 123) + value of HW from table1(which is 212) * value of column HW from table2 + value of WW from table1(which is 78) * value of column HW from table2.
So the output should be
P
123 + 212(143) +78(897) = 100305
123 + 212(987) +78(645) =
123 + 212(789) +78(656) =
123 + 212(123) +78(112) =
please any help would be nice......
Alternatively with proc tranpose and merge step to be more robust
data have1;
input par $ EST t;
cards;
Inter 123 7
HW 212 16
WW 78 5
;
data have2;
input FAMINC HW WW ;
cards;
122 143 897
432 987 645
212 789 656
132 123 112
;
proc transpose data=have1 out=trans;
var est;
run;
data have3;
merge have2 trans;
retain col1_ col2_ col3_;
array t(3) col1 col2 col3;
array t2(3) col1_ col2_ col3_;
do i = 1 to 3;
if t(i) ne . then t2(i)=t(i);
end;
j=1;
p=t2(j)+hw*t2(j+1)+ ww*t2(j+2);
run;
Please try
data have1;
input par $ EST t;
cards;
Inter 123 7
HW 212 16
WW 78 5
;
data have2;
input FAMINC HW WW ;
cards;
122 143 897
432 987 645
212 789 656
132 123 112
;
data have3;
set have2 ;
array t(3) (123 212 78);
i=1;
p=t(i)+hw*t(i+1)+ ww*t(i+2);
run;
Alternatively with proc tranpose and merge step to be more robust
data have1;
input par $ EST t;
cards;
Inter 123 7
HW 212 16
WW 78 5
;
data have2;
input FAMINC HW WW ;
cards;
122 143 897
432 987 645
212 789 656
132 123 112
;
proc transpose data=have1 out=trans;
var est;
run;
data have3;
merge have2 trans;
retain col1_ col2_ col3_;
array t(3) col1 col2 col3;
array t2(3) col1_ col2_ col3_;
do i = 1 to 3;
if t(i) ne . then t2(i)=t(i);
end;
j=1;
p=t2(j)+hw*t2(j+1)+ ww*t2(j+2);
run;
data have1;
input par $ EST t;
cards;
Inter 123 7
HW 212 16
WW 78 5
;
data have2;
input FAMINC HW WW ;
cards;
122 143 897
432 987 645
212 789 656
132 123 112
;
proc transpose data=have1 out=trans;
var est;
id par;
run;
data want;
set have2;
if _n_=1 then set trans(rename=(hw=_hw ww=_ww));
want=inter+_hw*hw+_ww*ww;
run;
It looks like you're scoring a model, can you use PROC SCORE?
It looks to be a linear model.
Or could you use the SCORE option/statement within the PROC you used? I suspect those solutions are easier than this.
http://blogs.sas.com/content/iml/2014/02/19/scoring-a-regression-model-in-sas.html
I tried PROC SCORE but it's not working.
I think on my other post before a week you suggested me PRCO SCORE. On my other code PROC SCORE is working fine. But for this code PROC SCORE is not wokring.
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.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.