BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
vivian_h
Calcite | Level 5

I was doing a research that needs longitudinal D-I-D method for pre-1 year and post -1 year, post-2 year and post-3 year. i followed the code from the sas support (https://support.sas.com/kb/61/830.html), I am not sure if the following codes are correct

 

I am also wondering how to test the parallel trend before using D-I-D model. 
"adrs" (0 1 ) is the treatment variable; "time" is the time variable  (0 1  2 ); outcome variable is "dmt" which is a binary variable (0 1)

proc genmod data=tmp. ss;
class id adrs time / ref=first;
model dmt = adrs time adrs*time;
repeated subject=id(adrs);
estimate "DID Post2(E-U)-Pre(E-U)" adrs*time 0 1 -1 0 -1 1;
estimate "DID Post1(E-U)-Pre(E-U)" adrs*time 1 0 -1 -1 0 1;
lsmeans adrs*time;
run;

Need SAS experts or statistic experts please !!!!

Thank you so much

1 ACCEPTED SOLUTION

Accepted Solutions
StatDave
SAS Super FREQ

If you are interested in trend and parallelism, then there should be a continuous predictor which can have a linear effect (a slope) in each group and then those slopes can be compared. The basic idea is discussed in this note. In your case, you presumably would treat TIME as continuous rather than as a CLASS variable. Then in the following model, the test of the ADRS*TIME interaction is a test of equal slopes (trends).

proc genmod data=tmp.ss;
class id adrs / ref=first;
model dmt = adrs time adrs*time;
repeated subject=id(adrs);
run;

Note that unless your ID values repeat in each ADRS level (like ID=1,2,3,... in each ADRS level), then you probably just need to specify SUBJECT=ID. See this note.

View solution in original post

4 REPLIES 4
StatDave
SAS Super FREQ

If you are interested in trend and parallelism, then there should be a continuous predictor which can have a linear effect (a slope) in each group and then those slopes can be compared. The basic idea is discussed in this note. In your case, you presumably would treat TIME as continuous rather than as a CLASS variable. Then in the following model, the test of the ADRS*TIME interaction is a test of equal slopes (trends).

proc genmod data=tmp.ss;
class id adrs / ref=first;
model dmt = adrs time adrs*time;
repeated subject=id(adrs);
run;

Note that unless your ID values repeat in each ADRS level (like ID=1,2,3,... in each ADRS level), then you probably just need to specify SUBJECT=ID. See this note.

vivian_h
Calcite | Level 5

Hii,

 

Thank you so much for replying.

 

So I would like to clarify if I need to test for parallel trend before the intervention:

my TIME variable stands for Pre-1 year, Pre-2 year, Pre-3 year
I can just fix the "TIME" variable as you showed in the solution

proc genmod data=tmp.ss;
class id adrs / ref=first;
model dmt = adrs time adrs*time;
repeated subject=id(adrs);
run;

To interpret, if the p-value of the interaction term "ADRS*TIME" is not less then 0.05 in each year then I can say it meets the parallel trend assumption

 

Am I correct?

 

I really appreciate your help!!

 

**and yes, in my case there will be repeated "ID"

StatDave
SAS Super FREQ
No, if the test of the interaction is significant (less than 0.5, or whatever criterion you want to use) then that indicates that the slopes are different and are not parallel.
vivian_h
Calcite | Level 5
Okay, I got it.
Thank you so much for clarifying!!!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 993 views
  • 5 likes
  • 2 in conversation