<?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 categorical variable based on date (before/after) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/creating-categorical-variable-based-on-date-before-after/m-p/521694#M141565</link>
    <description>&lt;P&gt;hi all,&lt;/P&gt;&lt;P&gt;I imported an xlsx file into university addition using the import snippet. Date is in MM/DD/YYYY format. I assume SAS doesn't know that so I wrote a format statement to clarify. I then tried to create a categorical variable "reg" based on the date. The code I used is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data sc.date;&lt;BR /&gt;set sc2;&lt;BR /&gt;format date mmddyy10.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data sc.change;&lt;BR /&gt;set sc.date;&lt;BR /&gt;if date &amp;lt; 06/06/2014 then reg = "before";&lt;BR /&gt;else reg = "after";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not getting any errors, however all of my observations have been assigned "after", even though many of them have a date prior to 6/6/2014.&lt;/P&gt;&lt;P&gt;Thanks in advance for any help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 15 Dec 2018 03:36:24 GMT</pubDate>
    <dc:creator>amigapomba</dc:creator>
    <dc:date>2018-12-15T03:36:24Z</dc:date>
    <item>
      <title>creating categorical variable based on date (before/after)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-categorical-variable-based-on-date-before-after/m-p/521694#M141565</link>
      <description>&lt;P&gt;hi all,&lt;/P&gt;&lt;P&gt;I imported an xlsx file into university addition using the import snippet. Date is in MM/DD/YYYY format. I assume SAS doesn't know that so I wrote a format statement to clarify. I then tried to create a categorical variable "reg" based on the date. The code I used is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data sc.date;&lt;BR /&gt;set sc2;&lt;BR /&gt;format date mmddyy10.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data sc.change;&lt;BR /&gt;set sc.date;&lt;BR /&gt;if date &amp;lt; 06/06/2014 then reg = "before";&lt;BR /&gt;else reg = "after";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not getting any errors, however all of my observations have been assigned "after", even though many of them have a date prior to 6/6/2014.&lt;/P&gt;&lt;P&gt;Thanks in advance for any help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Dec 2018 03:36:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-categorical-variable-based-on-date-before-after/m-p/521694#M141565</guid>
      <dc:creator>amigapomba</dc:creator>
      <dc:date>2018-12-15T03:36:24Z</dc:date>
    </item>
    <item>
      <title>Re: creating categorical variable based on date (before/after)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-categorical-variable-based-on-date-before-after/m-p/521695#M141566</link>
      <description>&lt;P&gt;SAS is seeing, 06/06/2014 which is 6 divided by 6, divided by 2014.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To specify a date, a specific format has to be used, the date9 format and enclosed in quotes and with a d at the end.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;if date &amp;lt; &lt;FONT size="4" color="#800080"&gt;&lt;STRONG&gt;'06Jun2014'd&lt;/STRONG&gt;&lt;/FONT&gt; then reg='Before';
else reg = 'After';&lt;/PRE&gt;
&lt;P&gt;Date and time literals:&lt;/P&gt;
&lt;P&gt;t &amp;nbsp; -&amp;gt; &amp;nbsp;time -&amp;gt; '08:00't&lt;/P&gt;
&lt;P&gt;dt -&amp;gt; datetime&lt;/P&gt;
&lt;P&gt;d &amp;nbsp;-&amp;gt; date&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/251357"&gt;@amigapomba&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;hi all,&lt;/P&gt;
&lt;P&gt;I imported an xlsx file into university addition using the import snippet. Date is in MM/DD/YYYY format. I assume SAS doesn't know that so I wrote a format statement to clarify. I then tried to create a categorical variable "reg" based on the date. The code I used is as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data sc.date;&lt;BR /&gt;set sc2;&lt;BR /&gt;format date mmddyy10.;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data sc.change;&lt;BR /&gt;set sc.date;&lt;BR /&gt;if date &amp;lt; 06/06/2014 then reg = "before";&lt;BR /&gt;else reg = "after";&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not getting any errors, however all of my observations have been assigned "after", even though many of them have a date prior to 6/6/2014.&lt;/P&gt;
&lt;P&gt;Thanks in advance for any help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/251357"&gt;@amigapomba&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;hi all,&lt;/P&gt;
&lt;P&gt;I imported an xlsx file into university addition using the import snippet. Date is in MM/DD/YYYY format. I assume SAS doesn't know that so I wrote a format statement to clarify. I then tried to create a categorical variable "reg" based on the date. The code I used is as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data sc.date;&lt;BR /&gt;set sc2;&lt;BR /&gt;format date mmddyy10.;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data sc.change;&lt;BR /&gt;set sc.date;&lt;BR /&gt;if date &amp;lt; 06/06/2014 then reg = "before";&lt;BR /&gt;else reg = "after";&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not getting any errors, however all of my observations have been assigned "after", even though many of them have a date prior to 6/6/2014.&lt;/P&gt;
&lt;P&gt;Thanks in advance for any help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Dec 2018 03:41:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-categorical-variable-based-on-date-before-after/m-p/521695#M141566</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-15T03:41:32Z</dc:date>
    </item>
    <item>
      <title>Re: creating categorical variable based on date (before/after)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-categorical-variable-based-on-date-before-after/m-p/521696#M141567</link>
      <description>&lt;P&gt;thank you!!&lt;/P&gt;</description>
      <pubDate>Sat, 15 Dec 2018 03:48:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-categorical-variable-based-on-date-before-after/m-p/521696#M141567</guid>
      <dc:creator>amigapomba</dc:creator>
      <dc:date>2018-12-15T03:48:40Z</dc:date>
    </item>
  </channel>
</rss>

