<?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: converting 5 digit date code in SAS Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Data-Science/converting-5-digit-date-code/m-p/163740#M1804</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Neither one of those variable look like they are character variables in SAS.&amp;nbsp; Why did you get the error about the format statement?&amp;nbsp; Perhaps because the variables are named DATE1 and DATE2 instead of DATE?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 12pt; font-family: 'courier new', courier;"&gt;date2=date2 -'01JAN1960'd + '01JAN1900'd -2 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 12pt; font-family: 'courier new', courier;"&gt;format date2 date9. ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;If DATE2 actually has the character string '42004' instead of the number 42,004 then you will need to make a new variable to hold the converted date.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 12pt; font-family: 'courier new', courier;"&gt;newdate=input(date2,32.) -'01JAN1960'd + '01JAN1900'd -2 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 12pt; font-family: 'courier new', courier;"&gt;format newdate date9. ;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 12 Feb 2015 03:30:02 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2015-02-12T03:30:02Z</dc:date>
    <item>
      <title>converting 5 digit date code</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/converting-5-digit-date-code/m-p/163735#M1799</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;When I import my data from excel to SAS, the date field (12/1/2014) comes as 5 digit (41651) code. Can anyone tell me how to turn it back to date (12JAN2014) format in sas?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Feb 2015 16:50:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/converting-5-digit-date-code/m-p/163735#M1799</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2015-02-11T16:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: converting 5 digit date code</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/converting-5-digit-date-code/m-p/163736#M1800</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is the Microsoft number of days since 1/1/1900 (most likely). To get a better SAS date you likely need&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another recent discussion that should help.&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://communities.sas.com/message/252679#252679"&gt;https://communities.sas.com/message/252679#252679&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Feb 2015 16:59:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/converting-5-digit-date-code/m-p/163736#M1800</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-02-11T16:59:46Z</dc:date>
    </item>
    <item>
      <title>Re: converting 5 digit date code</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/converting-5-digit-date-code/m-p/163737#M1801</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It seems to me that Excel here to count the days from 01JAN1900, while SAS does it from 01JAN1960. So there is a 60 years of difference. So there maybe something you could do before/during the importing, but if you already has it in SAS table, you can try: INTNX('YEAR', YOURDATE, -60); &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Feb 2015 17:03:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/converting-5-digit-date-code/m-p/163737#M1801</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2015-02-11T17:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: converting 5 digit date code</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/converting-5-digit-date-code/m-p/163738#M1802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So assuming you meant 12JAN2014 and not 01DEC2014 then your value is consistent with Excel's date numbering.&lt;/P&gt;&lt;P&gt;You can adjust it easily.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;date=date -'01JAN1960'd + '01JAN1900'd -2 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;format date date9. ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SAS and Excel don't count the first day the same way so you need to include the 2 day off set.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Feb 2015 17:43:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/converting-5-digit-date-code/m-p/163738#M1802</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-02-11T17:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: converting 5 digit date code</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/converting-5-digit-date-code/m-p/163739#M1803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tom, I tried '&lt;SPAN style="font-family: 'courier new', courier; font-size: 16px; background-color: #ffffff;"&gt;format date date9.'&lt;/SPAN&gt;, but it says i am trying to change character value to numeric. Actually in my excel file, date2 field was assigned as text. I formatted the excel data2 field to date format, but SAS is still importing date2 as text. Can you help me a bit more please.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my excel spreadsheet data look likes: &lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 162px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl66" height="20" width="75"&gt;Date1&lt;/TD&gt;&lt;TD class="xl67" width="87"&gt;Date2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20"&gt;12/31/2014&lt;/TD&gt;&lt;TD align="right" class="xl68"&gt;12/31/2014&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20"&gt;12/30/2014&lt;/TD&gt;&lt;TD align="right" class="xl68"&gt;12/30/2014&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20"&gt;12/29/2014&lt;/TD&gt;&lt;TD align="right" class="xl68"&gt;12/24/2014&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but after importing to SAS it look like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 162px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl64" height="20" width="75"&gt;Date1&lt;/TD&gt;&lt;TD class="xl65" width="87"&gt;Date2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl63" height="20"&gt;31DEC2014&lt;/TD&gt;&lt;TD align="right" class="xl66"&gt;42004&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl63" height="20"&gt;&lt;SPAN style="font-size: 13.3333330154419px; text-align: -webkit-right;"&gt;30DEC2014&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD align="right" class="xl66"&gt;&lt;SPAN style="font-size: 13.3333330154419px; text-align: -webkit-right;"&gt;42003&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl63" height="20"&gt;&lt;SPAN style="font-size: 13.3333330154419px; text-align: -webkit-right;"&gt;29DEC2014&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD align="right" class="xl66"&gt;41997&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl63" height="20"&gt;&lt;/TD&gt;&lt;TD align="right" class="xl66"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Feb 2015 00:42:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/converting-5-digit-date-code/m-p/163739#M1803</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2015-02-12T00:42:30Z</dc:date>
    </item>
    <item>
      <title>Re: converting 5 digit date code</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/converting-5-digit-date-code/m-p/163740#M1804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Neither one of those variable look like they are character variables in SAS.&amp;nbsp; Why did you get the error about the format statement?&amp;nbsp; Perhaps because the variables are named DATE1 and DATE2 instead of DATE?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 12pt; font-family: 'courier new', courier;"&gt;date2=date2 -'01JAN1960'd + '01JAN1900'd -2 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 12pt; font-family: 'courier new', courier;"&gt;format date2 date9. ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;If DATE2 actually has the character string '42004' instead of the number 42,004 then you will need to make a new variable to hold the converted date.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 12pt; font-family: 'courier new', courier;"&gt;newdate=input(date2,32.) -'01JAN1960'd + '01JAN1900'd -2 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 12pt; font-family: 'courier new', courier;"&gt;format newdate date9. ;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Feb 2015 03:30:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/converting-5-digit-date-code/m-p/163740#M1804</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-02-12T03:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: converting 5 digit date code</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/converting-5-digit-date-code/m-p/163741#M1805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Hi Tom'&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Can you please tell me what would be the code for creating multiple dataset from one dataset in one data step?&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Example: I have the following info dataset&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Name&amp;nbsp; City&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Country &lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;John&amp;nbsp;&amp;nbsp; New York&amp;nbsp; USA&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Albert Toronto&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Canada&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Alice&amp;nbsp; Sydney&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Australia&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;I want to create 3 dataset called USA, Canada and Australia from info dataset above. I tried the following way, but it's not working:&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;data usa canada australia;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;set info;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;if country='usa' then output usa;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;if country='Canada' then output Canada;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;if country='Australia' then output Australia;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;run;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;can anyone help please. Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 15 Feb 2015 23:12:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/converting-5-digit-date-code/m-p/163741#M1805</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2015-02-15T23:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: converting 5 digit date code</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/converting-5-digit-date-code/m-p/163742#M1806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually, it's two facts:&lt;/P&gt;&lt;P&gt;Excel counts the first day differently (legit), and it has a severe bug by considering 1900 a leap year (very much not legit). That's why there are 2 days difference and not just 1.&lt;/P&gt;&lt;P&gt;Note: LibreOffice/OpenOffice do not have the year 1900 bug and start counting at 31dec1899 to avoid different numbers than Excel. One of the reasons I prefer them over MS Office. There's actually developers/designers with brains there.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Feb 2015 06:34:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/converting-5-digit-date-code/m-p/163742#M1806</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-02-16T06:34:48Z</dc:date>
    </item>
    <item>
      <title>Re: converting 5 digit date code</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/converting-5-digit-date-code/m-p/163743#M1807</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Make sure the values match what you are testing.&amp;nbsp; In addition to case they might be "hidden" characters in you data such as leading spaces or tabs, carriage returns or other characters that will not be visible when printed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data info ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length name city country $20 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile cards dsd dlm='|' ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input name city country ;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;John|New York|USA&lt;/P&gt;&lt;P&gt;Albert|Toronto|Canada&lt;/P&gt;&lt;P&gt;Alice|Sydney|Australia&lt;/P&gt;&lt;P&gt;;;;;&lt;/P&gt;&lt;P&gt;data usa canada australia;&lt;/P&gt;&lt;P&gt;set info;&lt;/P&gt;&lt;P&gt;if lowcase(country)='usa' then output usa;&lt;/P&gt;&lt;P&gt;if lowcase(country)='canada' then output Canada;&lt;/P&gt;&lt;P&gt;if lowcase(country)='australia' then output Australia;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: There were 3 observations read from the data set WORK.INFO.&lt;/P&gt;&lt;P&gt;NOTE: The data set WORK.USA has 1 observations and 3 variables.&lt;/P&gt;&lt;P&gt;NOTE: The data set WORK.CANADA has 1 observations and 3 variables.&lt;/P&gt;&lt;P&gt;NOTE: The data set WORK.AUSTRALIA has 1 observations and 3 variables.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2015 19:06:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/converting-5-digit-date-code/m-p/163743#M1807</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-02-17T19:06:56Z</dc:date>
    </item>
    <item>
      <title>Re: converting 5 digit date code</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/converting-5-digit-date-code/m-p/163744#M1808</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your question was already sufficently answered here:&lt;/P&gt;&lt;P&gt;&lt;A __default_attr="71197" __jive_macro_name="thread" class="jive_macro jive_macro_thread" href="https://communities.sas.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Feb 2015 07:10:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/converting-5-digit-date-code/m-p/163744#M1808</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-02-18T07:10:13Z</dc:date>
    </item>
  </channel>
</rss>

