BookmarkSubscribeRSS Feed
Revere2323
Fluorite | Level 6

Hello,

 

I am looking to lag the exposure to outcome by a year. What I mean by this is that for a given year in my data, I want the exposure in one year to be associated with the outcome in the next, instead of the same year. This is because I want to avoid reverse causation. 

 

So if the exposure for 1999 is 26, I would want it to match with the outcome for 2000.

 

Here is my code without the lag:

 

PROC GENMOD data=data1;
CLASS StateID year (ref=first) event (ref=first);
MODEL Outcome =Exposure confounder / DIST=poisson LINK=log TYPE3 WALD offset=lnpop; 
REPEATED SUBJECT=stateid;
run;

 

I have an offset of state population and a repeated subject on stateID. Outcome is my main outcome and exposure is my main exposure. Confounder is a confounder. I do not think that the confounder should be lagged, just the main exposure and outcome.

 

Thanks so much!

1 REPLY 1
PGStats
Opal | Level 21

You could run your analysis on table data2 given by:

 

proc sql;
create table data2 as
select 
    a.*,
    b.Exposure as lastYearExposure
from 
    data1 as a inner join 
    data1 as b on a.stateId = b.stateId and b.year = a.year-1;
quit;

(untested)

 

PG

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 329 views
  • 0 likes
  • 2 in conversation