This seems like a really basic question. When creating a variable within a data step, is it possible to refer to that variable within the same data step? When I try to run the following code, I get the error "ERROR: Variable fthursDiag is not on file MAVEN.dd_aow_events". There are ways around this of course, but it is something I've run into a few times and have yet to find a solution for. data aow1; set maven.dd_aow_events; *-- convert dates; array date birth_date disease_status_date investigation_status_date diagnosis_date onset_date event_create_date event_modification_date; do over date; date=datepart(date); end; format birth_date disease_status_date investigation_status_date diagnosis_date onset_date event_create_date event_modification_date mmddyy10.; *-- create variable for first THURSDAY after diagnosis date; fthursDiag=diagnosis_date; if weekday(fthursDiag)=1 then fthursDiag = fthursDiag+4; if weekday(fthursDiag)=2 then fthursDiag = fthursDiag+3; if weekday(fthursDiag)=3 then fthursDiag = fthursDiag+2; if weekday(fthursDiag)=4 then fthursDiag = fthursDiag+1; if weekday(fthursDiag)=5 then fthursDiag = fthursDiag+0; if weekday(fthursDiag)=6 then fthursDiag = fthursDiag+6; if weekday(fthursDiag)=7 then fthursDiag = fthursDiag+5; format birth_date diagnosis_date fthursDiag mmddyy10.; *-- try to restrict data using the newly calculated variable; where fthursDiag <= date(); run;
... View more