<?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 Date format to SAS date trouble in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Date-format-to-SAS-date-trouble/m-p/823918#M325364</link>
    <description>&lt;P&gt;Hello everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having a little bit of trouble with some dates. I uploaded an excel and imported it to a SAS database with dates in format dd/mm/yyyy. I used the following code to change it to SAS date but I get missings in return. I have tried DATE9. and DDMMYY10.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;data dates;&lt;BR /&gt;set previous;&lt;BR /&gt;admdate=input(adm, DDMMYY8.);&lt;BR /&gt;format admdate;&lt;/P&gt;&lt;P&gt;run;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Jul 2022 18:07:41 GMT</pubDate>
    <dc:creator>MerAgSo</dc:creator>
    <dc:date>2022-07-18T18:07:41Z</dc:date>
    <item>
      <title>Date format to SAS date trouble</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format-to-SAS-date-trouble/m-p/823918#M325364</link>
      <description>&lt;P&gt;Hello everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having a little bit of trouble with some dates. I uploaded an excel and imported it to a SAS database with dates in format dd/mm/yyyy. I used the following code to change it to SAS date but I get missings in return. I have tried DATE9. and DDMMYY10.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;data dates;&lt;BR /&gt;set previous;&lt;BR /&gt;admdate=input(adm, DDMMYY8.);&lt;BR /&gt;format admdate;&lt;/P&gt;&lt;P&gt;run;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 18:07:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format-to-SAS-date-trouble/m-p/823918#M325364</guid>
      <dc:creator>MerAgSo</dc:creator>
      <dc:date>2022-07-18T18:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: Date format to SAS date trouble</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format-to-SAS-date-trouble/m-p/823926#M325368</link>
      <description>&lt;P&gt;Show us the unformatted values of ADM in your SAS data set named PREVIOUS.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 18:24:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format-to-SAS-date-trouble/m-p/823926#M325368</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-07-18T18:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: Date format to SAS date trouble</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format-to-SAS-date-trouble/m-p/823934#M325372</link>
      <description>They are already a SAS date. You can just format admdate date9., and that should change the display.</description>
      <pubDate>Mon, 18 Jul 2022 18:32:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format-to-SAS-date-trouble/m-p/823934#M325372</guid>
      <dc:creator>pink_poodle</dc:creator>
      <dc:date>2022-07-18T18:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: Date format to SAS date trouble</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format-to-SAS-date-trouble/m-p/823936#M325373</link>
      <description>&lt;P&gt;Before changing anything check what type of variable you have in the SAS dataset first.&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Is it numeric or character?&amp;nbsp;
&lt;UL&gt;
&lt;LI&gt;If numeric does it have a format attached to it?&amp;nbsp;
&lt;UL&gt;
&lt;LI&gt;Is it a date type format?&amp;nbsp; Like DATE, DDMMYY, MMDDYY, YYMMDD, etc?&amp;nbsp;&amp;nbsp;
&lt;UL&gt;
&lt;LI&gt;If so then there is nothing to do as you already have date values.&amp;nbsp; You could use a FORMAT statement to attach a different format so they dates are displayed differently.&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;No.&amp;nbsp; What do the values look like?&amp;nbsp; Look at some of them?&amp;nbsp; Are they number like 13,052,022 that a human might think of as a date in DDMMYYYY style?&amp;nbsp; &amp;nbsp;
&lt;UL&gt;
&lt;LI&gt;If so then first convert them to a string and then back to a date.&amp;nbsp; input(put(ADM,Z8.),ddmmyy8.)&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;If character then what do the values look like.&amp;nbsp;
&lt;UL&gt;
&lt;LI&gt;Are they strings like '13052022' that a human might recognize as a date in DDMMYYYY style?
&lt;UL&gt;
&lt;LI&gt;If so then your code should have worked.&amp;nbsp; Not your code will NOT work if the variable is numeric.&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;Are the strings strange digit strings that look like '44760'?
&lt;UL&gt;
&lt;LI&gt;If so then they are the raw numbers that EXCEL uses as dates converted into digit strings.&amp;nbsp; That happens when the column has some cells with dates and others with strings.
&lt;UL&gt;
&lt;LI&gt;Convert them to a number and correct for difference in how SAS and Excel count days.&amp;nbsp; input(adm,32.)+'30DEC1899'd&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 18:35:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format-to-SAS-date-trouble/m-p/823936#M325373</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-18T18:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: Date format to SAS date trouble</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format-to-SAS-date-trouble/m-p/823957#M325378</link>
      <description>&lt;P&gt;It is in numeric format and in DDMMYYYY10.&lt;/P&gt;&lt;P&gt;The thing is that I want to change it to SAS date format.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 19:22:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format-to-SAS-date-trouble/m-p/823957#M325378</guid>
      <dc:creator>MerAgSo</dc:creator>
      <dc:date>2022-07-18T19:22:45Z</dc:date>
    </item>
    <item>
      <title>Re: Date format to SAS date trouble</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format-to-SAS-date-trouble/m-p/823960#M325379</link>
      <description>&lt;P&gt;A FORMAT in SAS is instructions for how to display values as text.&amp;nbsp; If the variable is numeric then you have numeric values in the variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since the variable is numeric already you can replace the existing number with the date value and then just attach the format you want to use to display it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if you have a dataset named HAVE with a numeric variable named DATE with values like 13,102,021 and 01,051,989 then you can use a step like this to create a new dataset named WANT that has the numbers converted into dates that will display by default as string in MM/DD/YYYY pattern.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  date=input(put(date,z8.),mmddyy8.);
  format date mmddyy10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 19:32:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format-to-SAS-date-trouble/m-p/823960#M325379</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-18T19:32:23Z</dc:date>
    </item>
    <item>
      <title>Re: Date format to SAS date trouble</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format-to-SAS-date-trouble/m-p/823962#M325381</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/197667"&gt;@MerAgSo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;It is in numeric format and in DDMMYYYY10.&lt;/P&gt;
&lt;P&gt;The thing is that I want to change it to SAS date format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;There is no SAS format named DDMMYYYY.&amp;nbsp; &amp;nbsp;There is one named DDMMYY and others with a 7th letter to indicate the type of separator to use between the day month and year values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And what does the 10 mean there?&amp;nbsp; If you have a series of digits in DDMMYYYY style the longest it can be is 8 characters.&amp;nbsp; The only reason you would need 10 is to have room for the delimiter.&amp;nbsp; But there is no place to store a delimiter in a numeric variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you just mean that the digits of the number look like they could be the day,month and year of a date value?&amp;nbsp; Then convert the number to a string and then back to a date value using PUT() and INPUT() functions.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date=input(put(date,z8.),ddmmyy8.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if you mean that the variable is numeric and has the DDMMYY format &lt;STRONG&gt;attached&lt;/STRONG&gt; to it already then you already have date values.&amp;nbsp; So what is it you want to change?&amp;nbsp; Do you want to display the values in a different way?&amp;nbsp; Then use a FORMAT statement to attach a different format to the variable.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 19:43:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format-to-SAS-date-trouble/m-p/823962#M325381</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-18T19:43:32Z</dc:date>
    </item>
    <item>
      <title>Re: Date format to SAS date trouble</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format-to-SAS-date-trouble/m-p/823969#M325383</link>
      <description>&lt;P&gt;Sorry, the format is DDMMYY10. considering separators (/). I know this a date format but I want the numeric value given for SAS date value (The numeric value which counts days from January 1st, 1960). I need this in order to estimate several day differences among dates.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 20:15:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format-to-SAS-date-trouble/m-p/823969#M325383</guid>
      <dc:creator>MerAgSo</dc:creator>
      <dc:date>2022-07-18T20:15:42Z</dc:date>
    </item>
    <item>
      <title>Re: Date format to SAS date trouble</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format-to-SAS-date-trouble/m-p/823976#M325385</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/197667"&gt;@MerAgSo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Sorry, the format is DDMMYY10. considering separators (/). I know this a date format but I want the numeric value given for SAS date value (The numeric value which counts days from January 1st, 1960). I need this in order to estimate several day differences among dates.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It is the number of days already.&amp;nbsp; To get the difference in days between two dates just subtract.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;days_since = date2 - date1 ;
days_since_1960 = date ;
days_since_2000 = date - '01JAN2000'd ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Jul 2022 20:26:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format-to-SAS-date-trouble/m-p/823976#M325385</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-18T20:26:39Z</dc:date>
    </item>
  </channel>
</rss>

