%macro Generate_transformed_Scores
(variable=,
Has_Left=0,
Has_Right=0,
Left_value=0,
Right_Value=0,
Meaningful_Null=1,
condition1=LE-100000000,
condition2=LE-100000000,
condition3=LE-100000000,
condition4=LE-100000000,
condition5=LE-100000000,
condition6=LE-100000000,
condition7=LE-100000000,
condition8=LE-100000000,
condition9=LE-100000000);
&let variable1="&variable";
data transformation;
set &transform_para;
If var=&variable1;
format Null_score Slope Intercept b_score c_score d_score e_score f_Score g_score h_score i_score d19.14;
run;
Proc sql;
select Null_score into: Null_Score from transformation;
select Slope into: Slope from transformation; Select Intercept into: Intercept from transformation;
select b_Score into: b_score from transformation;
select c_Score into: c_score from transformation;
select d_Score into: d_score from transformation;
select e_Score into: e_score from transformation;
select f_Score into: f_score from transformation;
select g_Score into: g_score from transformation;
select h_Score into: h_score from transformation;
select i_Score into: i_score from transformation;
quit;
data transformed_score_temp (keep=&variable score &matchby);
set &relevant_tab;
format Null_score Slope Intercept b_score c_score d_score e_score f_score g_Score h_Score i_Score d19.4;
score=&variable*&slope +&intercept;
if &Has_LEft=1 then do;
if &variable<&Left_Value then score=&Left_Value*&slope +&intercept;
end;
if &Has_Right=1 then do;
if &Variable > &Right_Value then score=&Right_Value*&slope+&intercept;
end;
if &variable &condition9. then score=&i_score;
if &variable &conditioon8. then score=&h_score;
if &variable &conditioon7. then score=&g_score;
if &variable &conditioon6. then score=&f_score;
if &variable &conditioon5. then score=&e_score;
if &variable &conditioon4. then score=&d_score;
if &variable &conditioon3. then score=&c_score;
if &variable &conditioon2. then score=&b_score;
if &variable &conditioon1. then score=&Null_score;
if &variable =. and &Meaningful_Null=1 then score=&Null_score;
if &variable =. and &Meaningful_Null=0 then score=.;
run;
PROC SQL; create table transformed_Score_temp as select a.*, a.score as &variable._score from transformed_Score_Temp as a, transformation as b; quit; proc sql; create table transformed_score_mast as select a.*, b.&variable._score from transformed_score_mast as a left join transformed_score_temp as b on a.&IDField = b.&IDField and a.&IDField2=b.&IDField2; quit; proc sql; create table transformed_score as select a.*, b.score as &variable., b.&variable. as &variable._O from transformed_score_only as a left join transformed_Score_temp as b on a.&IDField=b.&IDField and a.&IDField2=b.&IDField2; quit; data transformed_score_only; set transformed_Score; run; %mend;
%Generate_transformed_scores (variables= (PctChangeBalance, Has_Left=1, HAs_Right=1, Left_Value=0, Right_Value=0.5, condition=>0.5, Meaningful_Null=0); %Generate_transformed_scores (variable=LongestOverdueMonth, Has_Left=0, Has_Right=0, condition1=>3, condition2=>=2, condition3=>1, condition4=<1, Meaningful_Null=0);
Hi All, I am facing these macros where I am not sure how to interpret especially the part about the conditions like the below:
if &variable &condition9. then score=&i_score;
if &variable &conditioon8. then score=&h_score;
if &variable &conditioon7. then score=&g_score;
What are we trying to achieve and what kind of return are we lightly to receive?
... View more