<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Difference in difference analysis for a binary outcome in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Difference-in-difference-analysis-for-a-binary-outcome/m-p/699156#M33723</link>
    <description>&lt;P&gt;I think your code for Question 1 will give what you need (although the ESTIMATE and LSMESTIMATE are redundant).&amp;nbsp; The trick then is to include at least the LSMEANS and LSMESTIMATE statements into the PROC SURVEYLOGISTIC code. You will need to output the results using ODS, and then call the %NLmeans macro to get the differences.&amp;nbsp; The documentation for the %NLmeans macro is in this note:&amp;nbsp;&lt;A href="https://support.sas.com/kb/62/362.html" target="_self"&gt;https://support.sas.com/kb/62/362.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SteveDenham&lt;/P&gt;</description>
    <pubDate>Mon, 16 Nov 2020 14:36:52 GMT</pubDate>
    <dc:creator>SteveDenham</dc:creator>
    <dc:date>2020-11-16T14:36:52Z</dc:date>
    <item>
      <title>Difference in difference analysis for a binary outcome</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Difference-in-difference-analysis-for-a-binary-outcome/m-p/698829#M33709</link>
      <description>&lt;P&gt;&lt;FONT size="2"&gt;Hello,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I am trying to conduct a difference in difference (DID) analysis&amp;nbsp;&lt;SPAN&gt;to examine the effect of an intervention on the prevalence of smoking using a national cross-sectional survey dataset (2010-2015). The outcome of interest is a binary variable (smoking: yes/no), and I am comparing states with and without the policy of interest.&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;I have been asked to run both a linear probability model (using proc surveyreg) and a logit model (using proc surveylogistic) to examine the effect of the policy in treated versus reference states.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;I have to get the following estimates:&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1) The average difference in the probability of smoking (treated versus reference states) from a linear probability model (i.e., estimate [95% CI])&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2) The pre-post changes in the odds of smoking (treated versus reference states) from a logit model (i.e., odds ratio [95% CI])&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;&lt;U&gt;Question 1&lt;/U&gt;: Does the coefficient obtained from the "lsmestimate" and "estimate" statement represent the DID estimate (i.e., the average difference in the probability of smoking)? &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;If not, how can I get the DID estimate as a probability with a 95% CI? Here is the code I was using:&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;&lt;STRONG&gt;proc surveyreg data&lt;/STRONG&gt;=survey_data;&lt;BR /&gt;&lt;STRONG&gt;domain&lt;/STRONG&gt; gender;&lt;BR /&gt;&lt;STRONG&gt;stratum&lt;/STRONG&gt; stratum_var;&lt;BR /&gt;&lt;STRONG&gt;cluster&lt;/STRONG&gt; cluster_var;&lt;BR /&gt;&lt;STRONG&gt;class&lt;/STRONG&gt; policy_time intervention covar1 covar2 covar3;&lt;BR /&gt;&lt;STRONG&gt;weight&lt;/STRONG&gt; weight_var;&lt;BR /&gt;&lt;STRONG&gt;model&lt;/STRONG&gt; smoking= policy_time intervention policy_time*intervention covar1 covar2 covar3 /&lt;STRONG&gt;CLPARM solution vadjust&lt;/STRONG&gt;=none;&lt;BR /&gt;&lt;STRONG&gt;estimate&lt;/STRONG&gt; "Diff in Diff" policy_time*intervention 1 -1 -1 1;&lt;BR /&gt;&lt;STRONG&gt;lsmeans&lt;/STRONG&gt; policy_time*intervention;&lt;BR /&gt;&lt;STRONG&gt;lsmestimate&lt;/STRONG&gt; policy_time*intervention "Diff in Diff" 1 -1 -1 1;&lt;BR /&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;&lt;U&gt;Question 2&lt;/U&gt;: How can I obtain the changes in the odds of smoking (treated versus reference states) as an odds ratio with a 95% CI?&amp;nbsp; Here is a sample code:&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;proc surveylogistic data&lt;/STRONG&gt;=survey_data;&lt;BR /&gt;&lt;STRONG&gt;domain&lt;/STRONG&gt; gender;&lt;BR /&gt;&lt;STRONG&gt;stratum&lt;/STRONG&gt; stratum_var;&lt;BR /&gt;&lt;STRONG&gt;cluster&lt;/STRONG&gt; cluster_var;&lt;BR /&gt;&lt;STRONG&gt;class&lt;/STRONG&gt; policy_time intervention covar1 covar2 covar3;&lt;BR /&gt;&lt;STRONG&gt;weight&lt;/STRONG&gt; weight_var;&lt;BR /&gt;&lt;STRONG&gt;model&lt;/STRONG&gt; smoking= policy_time intervention policy_time*intervention covar1 covar2 covar3;&lt;BR /&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;I appreciate any insight you can offer.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Nov 2020 16:22:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Difference-in-difference-analysis-for-a-binary-outcome/m-p/698829#M33709</guid>
      <dc:creator>lousam</dc:creator>
      <dc:date>2020-11-15T16:22:54Z</dc:date>
    </item>
    <item>
      <title>Re: Difference in difference analysis for a binary outcome</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Difference-in-difference-analysis-for-a-binary-outcome/m-p/699156#M33723</link>
      <description>&lt;P&gt;I think your code for Question 1 will give what you need (although the ESTIMATE and LSMESTIMATE are redundant).&amp;nbsp; The trick then is to include at least the LSMEANS and LSMESTIMATE statements into the PROC SURVEYLOGISTIC code. You will need to output the results using ODS, and then call the %NLmeans macro to get the differences.&amp;nbsp; The documentation for the %NLmeans macro is in this note:&amp;nbsp;&lt;A href="https://support.sas.com/kb/62/362.html" target="_self"&gt;https://support.sas.com/kb/62/362.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SteveDenham&lt;/P&gt;</description>
      <pubDate>Mon, 16 Nov 2020 14:36:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Difference-in-difference-analysis-for-a-binary-outcome/m-p/699156#M33723</guid>
      <dc:creator>SteveDenham</dc:creator>
      <dc:date>2020-11-16T14:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: Difference in difference analysis for a binary outcome</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Difference-in-difference-analysis-for-a-binary-outcome/m-p/699359#M33730</link>
      <description>&lt;P&gt;It's not entirely clear what comparison you want in question 2, but since you say you want an odds ratio, I assume you want to compare one or more pairs of the four combinations. In that case, just use the LSMEANS statement with the DIFF and ODDSRATIO options (and CL if you want confidence intervals) which will give each of the pairwise comparisons and the corresponding odds ratios. For example:&amp;nbsp; lsmeans policy_time*intervention / ilink diff oddsratio cl;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you again want an estimate of the DID on the mean scale, then see the second section of &lt;A href="https://support.sas.com/kb/61/830.html" target="_self"&gt;this note&lt;/A&gt; that shows how to obtain the DID on the means using the NLMeans macro. Or if pairwise differences in means are needed, that can also be done with NLMeans as shown in &lt;A href="http://support.sas.com/kb/37228" target="_self"&gt;this note&lt;/A&gt; (though not shown in the context of a model with interaction).&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2020 03:34:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Difference-in-difference-analysis-for-a-binary-outcome/m-p/699359#M33730</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2020-11-17T03:34:03Z</dc:date>
    </item>
    <item>
      <title>Re: Difference in difference analysis for a binary outcome</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Difference-in-difference-analysis-for-a-binary-outcome/m-p/700347#M33781</link>
      <description>&lt;P&gt;I apologize if my questions were unclear. For my second question, I wanted to get a DID estimate as an odds ratio from "proc surveylogistic". This odds ratio (95% CI) would represents the pre-post changes&amp;nbsp;in smoking among individuals in treated states relative to the individuals in the untreated states.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe there are several articles that provide a DID estimate using the following approaches:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - DID estimate as an odds ratio (obtained using logistic regression)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - DID estimate as &lt;SPAN&gt;the average difference in the probability of having the outcome of interest (obtained using linear regression)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Nov 2020 21:22:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Difference-in-difference-analysis-for-a-binary-outcome/m-p/700347#M33781</guid>
      <dc:creator>lousam</dc:creator>
      <dc:date>2020-11-19T21:22:26Z</dc:date>
    </item>
    <item>
      <title>Re: Difference in difference analysis for a binary outcome</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Difference-in-difference-analysis-for-a-binary-outcome/m-p/700381#M33782</link>
      <description>&lt;P&gt;"DID" means *difference" in difference. Odds ratios, being ratios, are not differences. So, again, if you want to estimate the difference in differences of the means, then use the NLMeans macro in the note I referred to. If you truly want odds ratios, instead of differences, then use the LSMEANS statement with DIFF and ODDSRATIO options.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Nov 2020 01:16:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Difference-in-difference-analysis-for-a-binary-outcome/m-p/700381#M33782</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2020-11-20T01:16:22Z</dc:date>
    </item>
  </channel>
</rss>

