<?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: Fixing Date with the first day of the month or year in SAS Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Data-Science/Fixing-Date-with-the-first-day-of-the-month-or-year/m-p/200926#M2672</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hey mlogan,&lt;/P&gt;&lt;P&gt;You can give it a try at writing a SAS macro that uses different formats/informats.&lt;/P&gt;&lt;P&gt;While you do that, a quick-and-dirty trick would be to fix that date column in Excel, and then import it to SAS. To make it the same in Excel, I would do as this steps (&lt;A href="https://support.office.com/en-us/article/Format-a-date-the-way-you-want-8e10019e-d5d8-47a1-ba95-db95123d273e" title="https://support.office.com/en-us/article/Format-a-date-the-way-you-want-8e10019e-d5d8-47a1-ba95-db95123d273e"&gt;Format a date the way you want&lt;/A&gt;) and maybe copy the column and paste as values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck!&lt;/P&gt;&lt;P&gt;-Miguel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 18 Aug 2015 11:50:13 GMT</pubDate>
    <dc:creator>M_Maldonado</dc:creator>
    <dc:date>2015-08-18T11:50:13Z</dc:date>
    <item>
      <title>Fixing Date with the first day of the month or year</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Fixing-Date-with-the-first-day-of-the-month-or-year/m-p/200925#M2671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;H&lt;/STRONG&gt;i All,&lt;/P&gt;&lt;P&gt;I have the following table in sas (start_date) that I imported from Excel. Data look weired because some data was entered as 05-FEB-2014, some as APR-2005 (without any day) and some as 2013 (without any day and month) in the excel spreadsheet that I imported the data from.&lt;/P&gt;&lt;P&gt;Can anyone show me how to fix them in sas according to:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;05-FEB-2014 = stays the same&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;APR-2005 = 01-&lt;SPAN style="font-size: 13.3333330154419px;"&gt;APR-2005 (first day of the month)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;2013 = 01-JAN-2013 (first day of the year)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;My output will look like this:&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Start_Date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; New Date&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;2011-00-00&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 13.3333330154419px;"&gt;01-JAN-2011&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;40073&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 17-SEP--2009&lt;/P&gt;&lt;P&gt;2009-03-00&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01-MAR-2009&lt;/P&gt;&lt;P&gt;37347&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01-APR-2002&lt;/P&gt;&lt;P&gt;1996-09-00&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01-SEP-1996&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Aug 2015 18:22:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Fixing-Date-with-the-first-day-of-the-month-or-year/m-p/200925#M2671</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2015-08-17T18:22:45Z</dc:date>
    </item>
    <item>
      <title>Re: Fixing Date with the first day of the month or year</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Fixing-Date-with-the-first-day-of-the-month-or-year/m-p/200926#M2672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hey mlogan,&lt;/P&gt;&lt;P&gt;You can give it a try at writing a SAS macro that uses different formats/informats.&lt;/P&gt;&lt;P&gt;While you do that, a quick-and-dirty trick would be to fix that date column in Excel, and then import it to SAS. To make it the same in Excel, I would do as this steps (&lt;A href="https://support.office.com/en-us/article/Format-a-date-the-way-you-want-8e10019e-d5d8-47a1-ba95-db95123d273e" title="https://support.office.com/en-us/article/Format-a-date-the-way-you-want-8e10019e-d5d8-47a1-ba95-db95123d273e"&gt;Format a date the way you want&lt;/A&gt;) and maybe copy the column and paste as values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck!&lt;/P&gt;&lt;P&gt;-Miguel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Aug 2015 11:50:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Fixing-Date-with-the-first-day-of-the-month-or-year/m-p/200926#M2672</guid>
      <dc:creator>M_Maldonado</dc:creator>
      <dc:date>2015-08-18T11:50:13Z</dc:date>
    </item>
    <item>
      <title>Re: Fixing Date with the first day of the month or year</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Fixing-Date-with-the-first-day-of-the-month-or-year/m-p/200927#M2673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Excel and SAS calculate dates from a different base date.&amp;nbsp; You may just be able to take 23546 off the Excel date to get what you want:&lt;/P&gt;&lt;P&gt;data tmp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; a=40073;&lt;/P&gt;&lt;P&gt;&amp;nbsp; b=a-23546;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format a b date9.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However as previous poster mentioned you would be far better off sorting the data out at source, and even better off by not using Excel - which is an unvalidated, unstructured, and basically unusable for any real purpose, bit of software.&amp;nbsp; If you want a data entry/storage, use a database, if you want a data transfer use an appropriate format - CSV, XML etc.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Aug 2015 12:43:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Fixing-Date-with-the-first-day-of-the-month-or-year/m-p/200927#M2673</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-08-18T12:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: Fixing Date with the first day of the month or year</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Fixing-Date-with-the-first-day-of-the-month-or-year/m-p/200928#M2674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello -&lt;/P&gt;&lt;P&gt;You may be able to take advantage of the MDY function (see: &lt;A class="active_link" href="https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000199044.htm"&gt;https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000199044.htm&lt;/A&gt;).&lt;/P&gt;&lt;P&gt;Basically you will need to read you current string (start_date), decompose it into month, day, year information - and use MDY to create the SAS date value (and apply a format later on so you can see the date in your preferred format).&lt;/P&gt;&lt;P&gt;If month or day are missing then you can simply replace the values with 1 to create first day or month dates.&lt;/P&gt;&lt;P&gt;For unformatted values (for example 40073)&amp;nbsp; RW9's tip can be applied I think.&lt;/P&gt;&lt;P&gt;Hope I'm making sense.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Udo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Aug 2015 17:05:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Fixing-Date-with-the-first-day-of-the-month-or-year/m-p/200928#M2674</guid>
      <dc:creator>udo_sas</dc:creator>
      <dc:date>2015-08-18T17:05:43Z</dc:date>
    </item>
  </channel>
</rss>

