<?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 creating dummy variable from dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/creating-dummy-variable-from-dates/m-p/566536#M159237</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create a dummy variable as follows;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;before 1st September 2016 as pre-intervention;&lt;/P&gt;&lt;P&gt;from 01/09/2016 to 28/02/2017 as intervention&lt;/P&gt;&lt;P&gt;After 28/02/2017 as post-intervention&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I run proc contents, the log says its in 'yymmdd10' format;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in proc print output log the dates look like for e.g.;&lt;/P&gt;&lt;P&gt;2018-06-18.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I write the following syntax;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data dummy;&lt;BR /&gt;set combined;&lt;BR /&gt;format EventDate YYMMDD10.;&lt;BR /&gt;if EventDate&amp;lt;'20160901'd then group=0;*intervention;&lt;BR /&gt;else if '20160901'd =&amp;lt;EventDate&amp;gt;= '20170228'd then group=1;*pre-intervention;&lt;BR /&gt;else group=2;*post-intervention;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it gives me an error message.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone help please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Shah&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 17 Jun 2019 12:01:15 GMT</pubDate>
    <dc:creator>sks521</dc:creator>
    <dc:date>2019-06-17T12:01:15Z</dc:date>
    <item>
      <title>creating dummy variable from dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-dummy-variable-from-dates/m-p/566536#M159237</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create a dummy variable as follows;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;before 1st September 2016 as pre-intervention;&lt;/P&gt;&lt;P&gt;from 01/09/2016 to 28/02/2017 as intervention&lt;/P&gt;&lt;P&gt;After 28/02/2017 as post-intervention&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I run proc contents, the log says its in 'yymmdd10' format;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in proc print output log the dates look like for e.g.;&lt;/P&gt;&lt;P&gt;2018-06-18.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I write the following syntax;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data dummy;&lt;BR /&gt;set combined;&lt;BR /&gt;format EventDate YYMMDD10.;&lt;BR /&gt;if EventDate&amp;lt;'20160901'd then group=0;*intervention;&lt;BR /&gt;else if '20160901'd =&amp;lt;EventDate&amp;gt;= '20170228'd then group=1;*pre-intervention;&lt;BR /&gt;else group=2;*post-intervention;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it gives me an error message.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone help please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Shah&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2019 12:01:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-dummy-variable-from-dates/m-p/566536#M159237</guid>
      <dc:creator>sks521</dc:creator>
      <dc:date>2019-06-17T12:01:15Z</dc:date>
    </item>
    <item>
      <title>Re: creating dummy variable from dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-dummy-variable-from-dates/m-p/566541#M159238</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/277970"&gt;@sks521&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;BR /&gt;if EventDate&amp;lt;'20160901'd then group=0;*intervention;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The proper syntax here is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if EventDate&amp;lt;'01SEP2016'd then group=0;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It doesn't matter what the format of the variable is, your date constant must be in the format shown.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2019 12:08:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-dummy-variable-from-dates/m-p/566541#M159238</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-06-17T12:08:35Z</dc:date>
    </item>
    <item>
      <title>Re: creating dummy variable from dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-dummy-variable-from-dates/m-p/566545#M159240</link>
      <description>&lt;P&gt;Fabulous! it worked&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2019 12:12:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-dummy-variable-from-dates/m-p/566545#M159240</guid>
      <dc:creator>sks521</dc:creator>
      <dc:date>2019-06-17T12:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: creating dummy variable from dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-dummy-variable-from-dates/m-p/566549#M159243</link>
      <description>&lt;P&gt;Your date constant is not right.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;'20160901'd&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;--&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;'01sep2016'd&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2019 12:32:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-dummy-variable-from-dates/m-p/566549#M159243</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-06-17T12:32:03Z</dc:date>
    </item>
  </channel>
</rss>

