<?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: Convert numeric yyyymm to sas date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-yyyymm-to-sas-date/m-p/841914#M332901</link>
    <description>&lt;P&gt;To become a successful coder, you&amp;nbsp;&lt;STRONG&gt;MUST&lt;/STRONG&gt; pay attention to details. You did not use the informat we both suggested.&lt;/P&gt;</description>
    <pubDate>Tue, 01 Nov 2022 17:06:16 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-11-01T17:06:16Z</dc:date>
    <item>
      <title>Convert numeric yyyymm to sas date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-yyyymm-to-sas-date/m-p/841905#M332895</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a date field in a numeric format as yyyymm (201603) and I'm trying to convert it to a date format ('01MAR2016'). The day doesn't matter as much because I'm only using this to be able to get 2016-03. And the only way I've found to get that format is by using a put statement for a date field.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated!&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 16:32:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-yyyymm-to-sas-date/m-p/841905#M332895</guid>
      <dc:creator>Sas_noob25</dc:creator>
      <dc:date>2022-11-01T16:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: Convert numeric yyyymm to sas date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-yyyymm-to-sas-date/m-p/841907#M332896</link>
      <description>&lt;P&gt;So you have a number like&amp;nbsp;201,603 and you want to interpret it as some day in March of 2016?&lt;/P&gt;
&lt;P&gt;You can convert it to a character string and then you could use an INFORMAT to convert it to a date value.&lt;/P&gt;
&lt;P&gt;You could then attach the YYMMD7. format specification to it to make it display in YYYY-MM style.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input number ;
cards;
201603
;

data want;
   set have;
   date_value = input(put(NUMBER,z6.),yymmn6.);
   format date_value yymmd7. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Nov 2022 16:40:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-yyyymm-to-sas-date/m-p/841907#M332896</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-11-01T16:40:41Z</dc:date>
    </item>
    <item>
      <title>Re: Convert numeric yyyymm to sas date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-yyyymm-to-sas-date/m-p/841909#M332898</link>
      <description>&lt;P&gt;First of all, you don't have a date value. You have a number which&amp;nbsp;&lt;EM&gt;looks&lt;/EM&gt; like a date-related value, but is not in reality.&lt;/P&gt;
&lt;P&gt;So you first must convert the number to a string, which can then be used as input for a function using a date informat.&lt;/P&gt;
&lt;P&gt;Sunce you already have a numeric variable, you can convert "in place":&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;numvar = input(put(numvar,z6.),yymmn6.);
format numvar yymmd7.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Nov 2022 16:43:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-yyyymm-to-sas-date/m-p/841909#M332898</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-11-01T16:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: Convert numeric yyyymm to sas date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-yyyymm-to-sas-date/m-p/841910#M332899</link>
      <description>&lt;P&gt;I tried this as well and I'm still getting blanks for my date2 field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data clean;&lt;BR /&gt;set clean;&lt;BR /&gt;date2= input(put(date1,z6.),yymmdd6.);&lt;BR /&gt;format date2 yymmd7.;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 16:45:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-yyyymm-to-sas-date/m-p/841910#M332899</guid>
      <dc:creator>Sas_noob25</dc:creator>
      <dc:date>2022-11-01T16:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: Convert numeric yyyymm to sas date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-yyyymm-to-sas-date/m-p/841911#M332900</link>
      <description>&lt;P&gt;You tried to read the string as if it had YYMMDD values.&amp;nbsp; But your description said that the values only had YYYYMM values instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the YYMMN informat, not the YYMMDD informat.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or append '01' and use the YYMMDD8. informat instead of YYMMDD6. informat.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 16:59:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-yyyymm-to-sas-date/m-p/841911#M332900</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-11-01T16:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: Convert numeric yyyymm to sas date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-yyyymm-to-sas-date/m-p/841914#M332901</link>
      <description>&lt;P&gt;To become a successful coder, you&amp;nbsp;&lt;STRONG&gt;MUST&lt;/STRONG&gt; pay attention to details. You did not use the informat we both suggested.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 17:06:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-yyyymm-to-sas-date/m-p/841914#M332901</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-11-01T17:06:16Z</dc:date>
    </item>
    <item>
      <title>Re: Convert numeric yyyymm to sas date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-yyyymm-to-sas-date/m-p/841931#M332904</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/284312"&gt;@Sas_noob25&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I tried this as well and I'm still getting blanks for my date2 field.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data clean;&lt;BR /&gt;set clean;&lt;BR /&gt;date2= input(put(date1,z6.),yymmdd6.);&lt;BR /&gt;format date2 yymmd7.;&lt;BR /&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;A value of 201603 read with yymmdd6 would treat 20 as the year (i.e. 2020 with likely system settings), 16 as the month (the MM part) and 03 as the day. Since there is no month 16 you would generate an invalid data message similar to this:&lt;/P&gt;
&lt;PRE&gt;NOTE: Invalid argument to function INPUT at line
&lt;/PRE&gt;
&lt;P&gt;with the line and column referencing where your INPUT function call was encountered.&lt;/P&gt;
&lt;P&gt;Did you read the log? I suspect that if all your dates are later than the year 2012 that every record generated an invalid data message until your limit setting was reached. Which would explain why the values were missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 17:58:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-yyyymm-to-sas-date/m-p/841931#M332904</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-11-01T17:58:56Z</dc:date>
    </item>
    <item>
      <title>Re: Convert numeric yyyymm to sas date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-yyyymm-to-sas-date/m-p/841959#M332909</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data number2date;
  n = 201603 ;

  format d date11.;
  d = MDY(mod(n,100),1,n/100);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 19:09:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-numeric-yyyymm-to-sas-date/m-p/841959#M332909</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2022-11-01T19:09:16Z</dc:date>
    </item>
  </channel>
</rss>

