@jsimmo02
Posting below even though things have moved on while I've been working out the code.
It's just another coding option for what you've got already.
data have;
infile datalines dlm='09'x truncover;
input Patient $ Year_admitted Smoking_Flag Delivery_Flag;
datalines;
x 2002 0 0
x 2003 1 0
x 2004 0 1
x 2006 0 1
x 2008 1 1
y 2004 0 1
z 2001 1 0
z 2001 0 1
;
run;
data want;
set have;
by Patient notsorted Year_admitted;
_r_sflg=lag(Smoking_Flag);
if first.patient then return;
/* also include delivery year for smoking flag */
AllConditionsMet= ( Delivery_Flag=1 and (Smoking_Flag=1 or _r_sflg=1) );
if AllConditionsMet=1 then output;
run;
... View more
Effects parameterization (or coding) compares each level to the average of all of the levels. Reference parameterization, which you used, compares each level to the reference level. To use effects coding, specify PARAM=EFFECT.
... View more
Look at the documentation of the WEIGHT statement for proc reg. This is most likely the way to go. Define w = 1 / stdErr**2; and use w in the weight statement.
... View more