<?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: How to convert numeric &amp;quot;201808&amp;quot; into actual DATE yymmn6.? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-numeric-quot-201808-quot-into-actual-DATE-yymmn6/m-p/529332#M144605</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/189060"&gt;@WorkingMan&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi, i have a column with the value of "201808" in numeric.&lt;/P&gt;
&lt;P&gt;I wish to convert this column in yymmn6. but i failed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sample code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  numPeriod =201808;
  format numPeriod yymm6.
  /*The code above will give me wrong value of 251707(or similar)*/

run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which part did i do wrongly?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;A date always has a day component not just the year and month.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you’re manually creating the date use MDY() function instead.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you’re trying to convert a number to a date, either do the math manually to get month/year. Or convert it to a character and then back to a number as a SAS date.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Date = input(put(oldDate, 8. -l), yymmn6.);
Format date yymmn6.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the yymmn6 throws an error you’ll need to find the right informat. I would probably add a 01 for the day at the end and use yymmdd10 if that happened.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 23 Jan 2019 04:16:10 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-01-23T04:16:10Z</dc:date>
    <item>
      <title>How to convert numeric "201808" into actual DATE yymmn6.?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-numeric-quot-201808-quot-into-actual-DATE-yymmn6/m-p/529327#M144601</link>
      <description>&lt;P&gt;Hi, i have a column with the value of "201808" in numeric.&lt;/P&gt;&lt;P&gt;I wish to convert this column in yymmn6. but i failed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  numPeriod =201808;
  format numPeriod yymm6.
  /*The code above will give me wrong value of 251707(or similar)*/

run ;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which part did i do wrongly?&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 03:57:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-numeric-quot-201808-quot-into-actual-DATE-yymmn6/m-p/529327#M144601</guid>
      <dc:creator>WorkingMan</dc:creator>
      <dc:date>2019-01-23T03:57:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert numeric "201808" into actual DATE yymmn6.?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-numeric-quot-201808-quot-into-actual-DATE-yymmn6/m-p/529332#M144605</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/189060"&gt;@WorkingMan&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi, i have a column with the value of "201808" in numeric.&lt;/P&gt;
&lt;P&gt;I wish to convert this column in yymmn6. but i failed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sample code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  numPeriod =201808;
  format numPeriod yymm6.
  /*The code above will give me wrong value of 251707(or similar)*/

run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which part did i do wrongly?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;A date always has a day component not just the year and month.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you’re manually creating the date use MDY() function instead.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you’re trying to convert a number to a date, either do the math manually to get month/year. Or convert it to a character and then back to a number as a SAS date.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Date = input(put(oldDate, 8. -l), yymmn6.);
Format date yymmn6.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the yymmn6 throws an error you’ll need to find the right informat. I would probably add a 01 for the day at the end and use yymmdd10 if that happened.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 04:16:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-numeric-quot-201808-quot-into-actual-DATE-yymmn6/m-p/529332#M144605</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-01-23T04:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert numeric "201808" into actual DATE yymmn6.?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-numeric-quot-201808-quot-into-actual-DATE-yymmn6/m-p/529344#M144610</link>
      <description>&lt;P&gt;Dates are the number of days since 1960.&amp;nbsp; 201,808 days after 1960&amp;nbsp; is pretty far in the future.&lt;/P&gt;
&lt;P&gt;You also need to pick an actual date, you cannot store a single number that represents 28,29,30 or 31 individual dates.&amp;nbsp; Generally the first of the month is used.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  numPeriod =201808;
  PeriodStart = mdy(mod(numPeriod,100),1,int(numPeriod/100));
  format numPeriod comma7. PeriodStart yymm6. ;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Jan 2019 06:21:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-numeric-quot-201808-quot-into-actual-DATE-yymmn6/m-p/529344#M144610</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-01-23T06:21:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert numeric "201808" into actual DATE yymmn6.?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-numeric-quot-201808-quot-into-actual-DATE-yymmn6/m-p/529355#M144615</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   numPeriod =201808;
   date=input(put(numPeriod, 8. -l), yymmn6.);
   
   put date date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Jan 2019 08:09:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-numeric-quot-201808-quot-into-actual-DATE-yymmn6/m-p/529355#M144615</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-01-23T08:09:11Z</dc:date>
    </item>
  </channel>
</rss>

