f



Re: difference-in-difference analysis

It strikes me that you might be able to write this as an analysis of =
covariance, where Y is your second time period measure, and one of your =
X variables is your first time period measure, such as:

proc glm data=3Dset1;
   class intervention;
   model time2_result=3D intervention time1_result =
intervention*time1_result;
run;

In this case all you'd have one line per subject.

-Mary
  ----- Original Message -----=20
  From: Anna D'Souza=20
  To: SAS-L@LISTSERV.UGA.EDU=20
  Sent: Tuesday, March 11, 2008 3:12 PM
  Subject: difference-in-difference analysis


  Hello,

  I have baseline and follow-up values for my intervention and control =
group.
  I want to conduct a difference-in-difference analysis. Y is =
continuous. i.e.

  Y =3D b0 + b1*Time + b2*Intervention + b3*(Intervention*Time) +b4Xn

  where Time is an indicator if the value is obtained at follow-up (1, =
0)
  Intervention is an indicator for being in the intervention group (1,0)
  Intervention*TIme is the interaction
  Xn: vector of all my other covariates.

  I understand the theory pretty well, but have not been able to find =
the SAS
  code to conduct this analysis.  Pl. advise on 2 things:
  1. How to arrange the data i.e. one line person or one line per person =
per
  time period?
  2. The code of course. Do you use PROC GENMOD or just PROC REG?

  I just heard about the LISTSERV, and the resources available, so I'm =
new to
  this forum.

  Thanks in advance for taking the time

  -- MG
0
mlhoward (1803)
3/11/2008 9:13:07 PM
comp.soft-sys.sas 142827 articles. 3 followers. Post Follow

0 Replies
1003 Views

Similar Articles

[PageSpeed] 54

Reply:

Similar Artilces:

Re: difference-in-difference analysis #2
Anna, I also found from the Archives a note from Dale McLerren. Perhaps this = might help: http://www.listserv.uga.edu/cgi-bin/wa?A2=3Dind0401c&L=3Dsas-l&F=3D&S=3D&= P=3D36265 Chunling, Assuming that you are modeling the response with both main effects X1 and X2 and the interaction X1*X2 included in the model, then you could run proc glm data=3Dmydata; class x2; model y =3D X1|X2 / solution; estimate "A increase by 0.1 (1)" x1 0.1 x2 0 1 x2*x1 0 0.1; estimate "A increase by 0.5 (2)" x1 0.5 x2 0 1 x2*x1 0 0.5; estimate "Diff in A (D1 =3D 1-2)" x1 -0.4 x2*x1 0 -0.4; estimate "B increase by 0.1 (3)" x1 0.1 x2 1 0 x2*x1 0.1 0; estimate "B increase by 0.5 (4)" x1 0.5 x2 1 0 x2*x1 0.5 0; estimate "Diff in B (D2 =3D 3-4)" x1 -0.4 x2*x1 -0.4 0; estimate "Diff of diff (D1 - D2)" x2*x1 0.4 -0.4; run; Note how I have built up to the final difference of differences. First, I have constructed the estimate for the response mean in group A for a change in X1 of 0.1 as well as a change in X1 of 0.5. Next, the estimate of the response mean in group A given a change of 0.1 minus the estimate of the response mean in group A given a change of 0.5 is obtained employing an estimate statement in which the terms of the seco...

Re: difference-in-difference analysis #4
> -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On > Behalf Of Anna D'Souza > Sent: Tuesday, March 11, 2008 1:13 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: difference-in-difference analysis > > Hello, > > I have baseline and follow-up values for my intervention and > control group. > I want to conduct a difference-in-difference analysis. Y is > continuous. i.e. > > Y = b0 + b1*Time + b2*Intervention + b3*(Intervention*Time) +b4Xn > > where Time is an indicator if the value is obtained at > follow-up (1, 0) > Intervention is an indicator for being in the intervention group (1,0) > Intervention*TIme is the interaction > Xn: vector of all my other covariates. > > I understand the theory pretty well, but have not been able > to find the SAS > code to conduct this analysis. Pl. advise on 2 things: > 1. How to arrange the data i.e. one line person or one line > per person per > time period? > 2. The code of course. Do you use PROC GENMOD or just PROC REG? > > I just heard about the LISTSERV, and the resources available, > so I'm new to > this forum. > > Thanks in advance for taking the time > > -- MG To answer your questions in order. 1. Since you have baseline and followup Y and you are talking about difference-in-differences, I would arrange the data as one line per person with a new dependent variable, newY = Yfollowup-...

Re: difference-in-difference analysis #3
MG, There are two possible ways to proceed assuming you are working with a continuous (normal distribution) response. Structure the file with a value of diff = y2 - y1, where y1 and y1 are collected at time 1 and 2 respectively: Dataset one: id y1 y2 diff group 1 9 8 1 1 2 8 10 -2 1 ... 11 8 6 2 2 12 6 9 -3 2 Then run: ODS SELECT tests3 solutionF; proc mixed data=one; class group id; model diff = group / solution; LSMEANS group / diff; run; The difference of a difference is the coefficient for the 'group' or the output from LSMEANS diff option. Or you can structure it as dataset two: Id y tm group 1 9 1 1 1 8 2 1 2 8 1 1 2 10 2 1 ... 11 8 1 2 11 6 2 2 12 6 1 2 12 9 2 2 You need to add the REPEATED statement to account for the correlation between y1 and y2: ODS SELECT tests3 solutionF estimates rcorr; PROC MIXED DATA= two; class group tm id; MODEL y = group|tm / solution; ESTIMATE 'group 1, time 1 - 2' tm 1 -1 group*tm 1 -1 0 0; ESTIMATE 'group 2, time 1 - 2' tm 1 -1 group*tm 0 0 1 -1; ESTIMATE 'Diff of diff' group*tm 1 -1 -1 1; REPEATED tm / subject=id type=un rcorr; run; The diff of a diff is either the value of the final ESTIMATE statement, or the non-zero coefficient for the group*tm interaction term from the solutionF table. You can also add in covariates to each model; the value of the pretest, y1 is often of interes...

difference-in-difference analysis
Hello, I have baseline and follow-up values for my intervention and control group. I want to conduct a difference-in-difference analysis. Y is continuous. i.e. Y = b0 + b1*Time + b2*Intervention + b3*(Intervention*Time) +b4Xn where Time is an indicator if the value is obtained at follow-up (1, 0) Intervention is an indicator for being in the intervention group (1,0) Intervention*TIme is the interaction Xn: vector of all my other covariates. I understand the theory pretty well, but have not been able to find the SAS code to conduct this analysis. Pl. advise on 2 things: 1. How to arrange the data i.e. one line person or one line per person per time period? 2. The code of course. Do you use PROC GENMOD or just PROC REG? I just heard about the LISTSERV, and the resources available, so I'm new to this forum. Thanks in advance for taking the time -- MG ...

Re: SAS/OR: PROC OPTMODEL giving different solutions on different
Do the machines have the same O.S. and do they have the same SAS updates and hot fixes? Are they from different manufacturers? You may want to contact SAS tech support 919-677-8008 Nat Wooding Environmental Specialist III Dominion, Environmental Biology 4111 Castlewood Rd Richmond, VA 23234 Phone:804-271-5313, Fax: 804-271-2977 Cel Phone: 804-205-0752 Stats Guy <thatstatsguy@GMA IL.COM> To Sent by: "SAS(r) SAS-L@LISTSERV.UGA.EDU Discussion"...

Re: Difference in days between two different SAS dates: Code resu lts in wrong difefrences
Leslie: Try: data DIFF ; set DATA ; DIFFDAY = range(DATEVAR1, datepart(DATEVAR2) ); run ; Sig -----Original Message----- From: Leslie Fisher [mailto:lfisher@METHOD-CONSULT.DE] Sent: Wednesday, November 19, 2003 1:30 PM To: SAS-L@LISTSERV.UGA.EDU Subject: AW: Difference in days between two different SAS dates: Code results in wrong difefrences Hi, I've checked all your wonderful proposols, however, none works. Code sample: data DIFF ; DIFFDAY = range(DATEVAR1, datepart(DATEVAR2) ); set DATA ; run ; All result in wrong re...

Re: Difference Between PC SAS and UNIX SAS
I'm not aware of any differences in SAS. For sure, there are some differences for external interfaces. E.g. there are no drive letters in UNIX (C:\a\b\). Normally the path delimiters are slashes (/) instead on back-slashes (\) in UNIX, but you can use both in SAS (c:/a/b). And all the commands are different (cp instead of copy, ls instead of dir, mkdir instead of md, ...) As far as you don't need that external commands, SAS is all the same on both platforms. Some limitations could be different - not the SAS limits, but OS limits. A few years ago you could not have more than 2 GB as dataset size (that limitations is gone for long time, only as example). There might be a difference. On Thu, 5 Jun 2008 11:28:09 -0700, Suthakar Iyer <suthakariyer@YAHOO.COM> wrote: >Hi, >Whether there is any difference between PC SAS and UNIX SAS &nbsp;from the functionality or user point of view. >&nbsp; >If there is a difference , kindly can you mention it. >&nbsp; >Thanks for the help in advance. >&nbsp; >Suthakar >&nbsp; >&nbsp; ...

Re: Different Syntax for Different Assemblers
"James" <spamtrap@crayne.org> wrote in message news:1118851680.920342.142400@g44g2000cwa.googlegroups.com... > Hi all, > I've just started learing assembly language and have obtained some > tutorials and the MASM assembler for use. However, the tutorials assume > that the reader have the TASM. I just want to know whether different > assemblers( here MASM and TASM) have different syntax for the assembly > code or not. Also if the code written for TASM is incompatible with > MASM then what can I do to solve the problem? > > Many thanks in advance,...

Re: Different WHERE statements for different variables?
I don't think so, it's possible in any Data or Proc step, since SAS always considers the most recent WHERE clause and replace it with the previous defined WHERE clauses: Mean is calculated only based on the final where statement: and a note in log: WHERE clause has been replaced. Proc summary data=sashelp.class mean print; where sex='F'; var height; where age>14; var weight; where height > 60; var age; Run; On Wed, Feb 11, 2009 at 7:55 AM, Gary <gshyoung@gmail.com> wrote: > Hi all, > > I've always wondered, but never gotten to work, whether it is possible > to have different WHERE statements for different variables? For > example, if I run a PROC SUMMARY on variables x, y and z, would it be > possible to have one WHERE condition apply to x, another to y, and > another to z? What about a PROC SQL? > > Many thanks, > G. > ...

Re: LSMEANS/ Difference in Difference Approach
Dear SAS L'ers, I have been asked to implement the "difference-in-difference" approach -following up on an old post last September. I received some very helpful suggestions- but still don't have a concrete way to implement this. I developed a way to directly code the coefficients in a data step-but its still very time consuming since I have multiple comparisons and multiple outcomes. To recap: In its simplest form the DD method provides an assessment of the difference between the changes in the means for a treatment and comparison group over a fixed time period. If the mea...

Re: Different images... different days
Is there a script out there that will let me load a new flash movie int a table dependent on the day of the week? Say I have seven flash (Mon, Tues, Wed, etc) ads that I want to appea on the corresponding days of the week? Thanks in advance. Stev - flashbu "flashbum" <flashbum.12500s@mail.forum4designers.com> wrote in message news:flashbum.12500s@mail.forum4designers.com... > > Is there a script out there that will let me load a new flash movie into > a table dependent on the day of the week? > > Say I have seven flash (Mon, Tues, Wed, etc) ads that I w...

Re: Difference Between PC SAS and UNIX SAS #2
I cannot give a complete list by any means for these two systems but there are functions listed in TS486 that are specific to windows and afaik, Sleep is one of these. I suggest that you look at the Companion to the ... Operating System in the online docs for each of these and compare the two systems. Nat Wooding Environmental Specialist III Dominion, Environmental Biology 4111 Castlewood Rd Richmond, VA 23234 Phone:804-271-5313, Fax: 804-271-2977 Suthakar Iyer <suthakariyer@YAH OO.COM> To Sent by: "SAS(r) SAS-L@LISTSERV.UGA.EDU Discussion" cc <SAS-L@LISTSERV.U GA.EDU> Subject Difference Between PC SAS and UNIX SAS 06/05/2008 02:28 PM Please respond to suthakariyer@yaho o.com Hi, Whether there is any difference between PC SAS and UNIX SAS &nbsp;from the functionality or user point of view. &nbsp; If there is a difference , kindly can you mention it. &nbsp; Thanks for the help in advance. &nbsp; Suthakar &nbsp; &nbsp; ----------------------------------------- CONFIDENTIALITY NOTICE: This electronic message contains information w...

Re: Difference Between PC SAS and UNIX SAS #3
On Fri, 6 Jun 2008 05:51:32 -0700, Lou <lpogoda@HOTMAIL.COM> wrote: >On Jun 5, 11:50 pm, PaulOK <nancynpaul-s...@yahoo.com> wrote: >> On Jun 5, 5:53 pm, "Lou" <lpog...@verizon.net> wrote: >> .... >> >> > In my limited experience, there are minor programming differences - you use >> > a forward slash instead of a backward slash in path names for example, >> >> .... >> Actually one can use either forward or backward slashes in Windows SAS >> programs. > >Yes one can use either in SAS for Windows, but not in SAS for Unix > >> >> libname datalib "c:/data/project/work"; >> >> works exactly the same as >> >> libname datalib "c:\data\project\work"; >> >> .... >> >> > Lastly, the documentation for SAS on Unix is riddled with misinformation and >> > in some cases is flatly wrong - obviously copied from some other platform >> > (probably Windows) and not checked for accuracy or applicability. >> >> Could you provide a specific example where the UNIX SAS documentations >> is 'flatly wrong'. > > >I'm not currently working in a place that has a unix environment, so >this is from memory. Where I was working a couple of years ago, the >company had made the decision to go to SAS on Unix, bought a shiny new >server, installed SAS, etc. I was par...

Re: Difference Between PC SAS and UNIX SAS but getting off topic
Naveen wrote: "Long/short: Get to know and be very nice to your local systems administrator. Then PC SAS = UNIX SAS" meaning that the system admin controls the resources available to your jobs and you want the admin to like you. This brings to mind a tale of back in the days when jobs were submitted on decks of punch cards. Long jobs might fill a card box but smaller ones were held together with rubber bands. At the computing center in Ames, Iowa, supposedly if you wanted special treatment, you might slip a piece of hard candy under the rubber band. Nat Wooding Environmental Specialist III Dominion, Environmental Biology 4111 Castlewood Rd Richmond, VA 23234 Phone:804-271-5313, Fax: 804-271-2977 NMani <naveen.manivanna n@GMAIL.COM> To Sent by: "SAS(r) SAS-L@LISTSERV.UGA.EDU Discussion" cc <SAS-L@LISTSERV.U GA.EDU> Subject Re: Difference Between PC SAS and UNIX SAS 06/06/2008 02:02 PM Please respond to NMani <naveen.manivanna n@GMAIL.COM> On Jun 5, 1:28 pm, suthakari...@yahoo.com (Suthakar Iyer) wrote: > Hi, > Whether the...

Re: Sas Question (Re-organizing dataset)
> -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On > Behalf Of wardnine@HOTMAIL.COM > Sent: Monday, September 18, 2006 4:25 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: [SPAM:] - Sas Question (Re-organizing dataset) - > Email has different SMTP TO: and MIME TO: fields in the email > addresses > > Suppose I have a dataset with the variables name, code1, > code2, code3, and amount. The dataset is thousands of lines > long, but here is a 3-line sample (the order of the 5 > variables of data is the same as the order of the...

Re: Different WHERE statements for different variables? #9
On 2/11/09, Mary <mlhoward@avalon.net> wrote: > Karma, > > Since you are nominated for SAS-L rookie of the year, I wonder if you might > want to explain how it is that you are new to SAS-L and yet know things like this? I don't think Karma's program produces the correct output. At least as I see it. Or where you referring to WHERE ALSO. > > Our SAS-L Rookie nominations, with Karma, Joe Matise, and Akshaya all seem to have > great depth to them, which is great! New to SAS-L don't necessarly mean new to SAS. > > Mary Howard > > ----- Original Message ----- > From: karma > To: SAS-L@LISTSERV.UGA.EDU > Sent: Wednesday, February 11, 2009 8:21 AM > Subject: Re: Different WHERE statements for different variables? > > > What about the also statement? > > Proc summary data=sashelp.class mean print; > where sex='F'; var height; > where also age>14; var weight; > where also height > 60; var age; > Run; > > log: > > NOTE: There were 2 observations read from the data set SASHELP.CLASS. > WHERE (sex='F') and (age>14) and (height>60); > > 2009/2/11 Akshaya Nathilvar <akshaya.nathilvar@gmail.com>: > > I don't think so, it's possible in any Data or Proc step, since SAS always > > considers the most recent WHERE clause and replace it with the previous > > defined WHERE clauses: > &...

Re: Different WHERE statements for different variables? #13
data _null_, Yes, I was referring to knowing "where also", but actually, it doesn't produce the right results in this case, since it is=20 cumulative of the where clauses so far. But of course we do not expect rookies to know as much as Most Valuable Persons do :-) -Mary (current SAS-L Rookie of the Year :-))=20 p.s ...and data _null_ is the current MVS of the Year. ----- Original Message -----=20 From: ./ ADD NAME=3DData _null_;=20 To: SAS-L@LISTSERV.UGA.EDU=20 Sent: Wednesday, February 11, 2009 11:26 AM Subject: Re: Different WHERE statements for different variables? I don't think Karma's program produces the correct output. At least as I see it. Or where you referring to WHERE ALSO. ...

Re: Different WHERE statements for different variables? #6
I don't see the reason, why that should be possible? Why not bring it all into ONE where clause? That might be a problem with the logic, but it is possible to fit all subsetting logic together. Note that where is always active on the input table, so local (derived) variables could not be part of it! Gerhard On Wed, 11 Feb 2009 09:12:11 -0500, Akshaya Nathilvar <akshaya.nathilvar@GMAIL.COM> wrote: >I don't think so, it's possible in any Data or Proc step, since SAS always >considers the most recent WHERE clause and replace it with the previous >defined WHERE clauses: >Mean is calculated only based on the final where statement: and a note in >log: WHERE clause has been replaced. > >Proc summary data=sashelp.class mean print; > where sex='F'; var height; > where age>14; var weight; > where height > 60; var age; >Run; > > > >On Wed, Feb 11, 2009 at 7:55 AM, Gary <gshyoung@gmail.com> wrote: > >> Hi all, >> >> I've always wondered, but never gotten to work, whether it is possible >> to have different WHERE statements for different variables? For >> example, if I run a PROC SUMMARY on variables x, y and z, would it be >> possible to have one WHERE condition apply to x, another to y, and >> another to z? What about a PROC SQL? >> >> Many thanks, >> G. >> ...

Re: Different WHERE statements for different variables? #5
I keep forgetting about the Where Also statement. Thanks Karma! On Wed, Feb 11, 2009 at 9:21 AM, karma <dorjetarap@googlemail.com> wrote: > What about the also statement? > > Proc summary data=sashelp.class mean print; > where sex='F'; var height; > where also age>14; var weight; > where also height > 60; var age; > Run; > > log: > > NOTE: There were 2 observations read from the data set SASHELP.CLASS. > WHERE (sex='F') and (age>14) and (height>60); > > 2009/2/11 Akshaya Nathilvar <akshaya.nathilvar@gmail.com>: > > I don't think so, it's possible in any Data or Proc step, since SAS > always > > considers the most recent WHERE clause and replace it with the previous > > defined WHERE clauses: > > Mean is calculated only based on the final where statement: and a note in > > log: WHERE clause has been replaced. > > > > Proc summary data=sashelp.class mean print; > > where sex='F'; var height; > > where age>14; var weight; > > where height > 60; var age; > > Run; > > > > > > > > On Wed, Feb 11, 2009 at 7:55 AM, Gary <gshyoung@gmail.com> wrote: > > > >> Hi all, > >> > >> I've always wondered, but never gotten to work, whether it is possible > >> to have different WHERE statements for different variables? Fo...

Re: Different WHERE statements for different variables? #18
Thanks for the compliment Mary. Although Data _null_ is correct in that the program is wrong, I was simply trying to demonstrate "where augmentation" with Akshaya's code. I'm putting it down as a rookie mistake ;-) The 'where also' is one of the many things that I learnt from this list after being fortunate enough to find the list pretty early on. I wrote my first SAS program on the 15th October 2007 and I think I posted my first question about a month and half later. At which point I was using macro's to do everything and I stored almost everything in global macro variables, but that was slapped out of me pretty quick on this list. I think one of the best ways to learn, is searching SAS-L and reading old posts from BOF winners, you certainly pick up a lot of gems. The only problem is I have been a bit too busy recently. Karma 2009/2/11 Mary <mlhoward@avalon.net>: > data _null_, > > Yes, I was referring to knowing "where also", but actually, > it doesn't produce the right results in this case, since it is > cumulative of the where clauses so far. > > But of course we do not expect rookies to know as much > as Most Valuable Persons do :-) > > -Mary (current SAS-L Rookie of the Year :-)) > p.s ...and data _null_ is the current MVS of the Year. > > > ----- Original Message ----- > From: ./ ADD NAME=Data _null_; > To: SAS-L@LISTSERV.UGA.EDU > Sent: Wednesday, February 11...

Re: Different WHERE statements for different variables? #17
Like you said, SQL is one option: proc sql; select distinct sex, mean(case when weight > 100 then weight else . end) as meanwtgt100, mean(case when height < 55 then height else . end) as meanhtlt55, cv(case when age < 15 then weight else . end) as cvwtagelt15 from sashelp.class group by sex ; Sex meanwtgt100 meanhtlt55 cvwtagelt15 ----------------------------------------- F 109.875 51.3 21.4851 M 125.1 . 17.89484 As you can see, different conditions were applied to different variables. Note that most of descriptive statistics can be calculated by SQL, but there are exceptions, such as Median. On Wed, 11 Feb 2009 04:55:17 -0800, Gary <gshyoung@GMAIL.COM> wrote: >Hi all, > >I've always wondered, but never gotten to work, whether it is possible >to have different WHERE statements for different variables? For >example, if I run a PROC SUMMARY on variables x, y and z, would it be >possible to have one WHERE condition apply to x, another to y, and >another to z? What about a PROC SQL? > >Many thanks, >G. ...

Re: Different WHERE statements for different variables? #3
could you provide a example, what you expect? Is where x=1 or y>9 not enough? Gerhard On Wed, 11 Feb 2009 04:55:17 -0800, Gary <gshyoung@GMAIL.COM> wrote: >Hi all, > >I've always wondered, but never gotten to work, whether it is possible >to have different WHERE statements for different variables? For >example, if I run a PROC SUMMARY on variables x, y and z, would it be >possible to have one WHERE condition apply to x, another to y, and >another to z? What about a PROC SQL? > >Many thanks, >G. ...

Re: Different WHERE statements for different variables? #2
If I undertand the question I think a VIEW would be a way to achieve different subset for different variables. data classV / view=classV; set sashelp.class; if age eq 12 then weight = .; if weight gt 60 then height = .; run; proc means nway missing; class sex; run; On 2/11/09, Gary <gshyoung@gmail.com> wrote: > Hi all, > > I've always wondered, but never gotten to work, whether it is possible > to have different WHERE statements for different variables? For > example, if I run a PROC SUMMARY on variables x, y and z, would it be > possible to have one WHERE condition apply to x, another to y, and > another to z? What about a PROC SQL? > > Many thanks, > G. > ...

Re: Different WHERE statements for different variables? #8
hi ... well, not PROC SUMMARY or PROC SQL, and not WHERE statements, but WHERE data set options with different variables ... data males (where=(sex eq 'M')) age_10_12 (where=(age between 10 and 12)) ; set sashelp.class; run; -- Mike Zdeb U@Albany School of Public Health One University Place Rensselaer, New York 12144-3456 P/518-402-6479 F/630-604-1475 > Hi all, > > I've always wondered, but never gotten to work, whether it is possible > to have different WHERE statements for different variables? For > example, if I run a PROC SUMMARY on variables x, y and z, would it be > possible to have one WHERE condition apply to x, another to y, and > another to z? What about a PROC SQL? > > Many thanks, > G. > > ...

Web resources about - Re: difference-in-difference analysis - comp.soft-sys.sas

Resources last updated: 3/17/2016 10:20:39 AM