Hi,
I have this code that merges regression parameters (param.lfp) to an micro dataset (pop_lfp1). The regression file is organised in a way that each variable has its own column with their specific categories on different lines and parameters corresponding to these categories being on another column (see attached file). The point of the merge is to have for each individuals of pop_lfp1 the regression parameters that correspond to their own characteristics. Since the code is repeating for each variable (intercept, edu, agegr, etc.), I'd like to have a macro that makes it shorter, in which I could just declare variables to merge in parameters.
proc sql;
create table pop_lfp1 as
select
p.*,
t1.intercept, t2.edu_p, t3.agegr_p, t4.agegr_edu_p,
t5.young_kid_p, t6.young_kid_edu_p, t7.region_p
from
pop2 p
left join
( select sex, intercept
from param.lfp
where not missing(intercept)
) t1
on p.sex=t1.sex
left join
( select sex, edu, edu_p
from param.lfp
where not missing(edu_p)
)t2
on p.sex=t2.sex and p.edu=t2.edu
left join
( select sex, agegr, agegr_p
from param.lfp
where not missing(agegr_p)
)t3
on p.sex=t3.sex and p.agegr=t3.agegr
left join
( select sex, agegr, edu, agegr_edu_p
from param.lfp
where not missing(agegr_edu_p)
)t4
on p.sex=t4.sex and p.agegr=t4.agegr and p.edu=t4.edu
left join
( select sex, young_kid, young_kid_p
from param.lfp
where not missing(young_kid_p)
)t5
on p.sex=t5.sex and p.young_kid=t5.young_kid
left join
( select sex, edu, young_kid, young_kid_edu_p
from param.lfp
where not missing(young_kid_edu_p)
)t6
on p.sex=t6.sex and p.edu=t6.edu and p.young_kid=t6.young_kid
left join
( select sex, region, region_p
from param.lfp
where not missing(region_p)
)t7
on p.sex=t7.sex and p.region=t7.region;
quit;
... View more