<?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 Converting Macro Date to yymmn6. format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Converting-Macro-Date-to-yymmn6-format/m-p/373464#M276205</link>
    <description>&lt;P&gt;I have a macro date which I am trying to convert to a yymmn6. format. ie."201707"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems simple&amp;nbsp;enough.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let dte = 07072017;&lt;BR /&gt;&amp;nbsp;%let dte_9 = %sysfunc(inputn(&amp;amp;dte,ddmmyyyyn8.),yymonn7.);&lt;BR /&gt;%put &amp;amp;dte_9;&lt;BR /&gt;7072017&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when I use yymonn7. as the format for the %sysfunc&amp;nbsp;I get "7072017"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when I change the format to yymmn6. I get Jibberish.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let dte = 07072017;&lt;BR /&gt;%let dte_9 = %sysfunc(inputn(&amp;amp;dte,ddmmyyyyn8.),yymmn6.);&lt;BR /&gt;%put &amp;amp;dte_9;&lt;BR /&gt;******&lt;/P&gt;&lt;P&gt;Why is the date outputted as * ? What can I do to get the date of "201707" ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Jul 2017 00:30:04 GMT</pubDate>
    <dc:creator>danshek</dc:creator>
    <dc:date>2017-07-06T00:30:04Z</dc:date>
    <item>
      <title>Converting Macro Date to yymmn6. format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Macro-Date-to-yymmn6-format/m-p/373464#M276205</link>
      <description>&lt;P&gt;I have a macro date which I am trying to convert to a yymmn6. format. ie."201707"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems simple&amp;nbsp;enough.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let dte = 07072017;&lt;BR /&gt;&amp;nbsp;%let dte_9 = %sysfunc(inputn(&amp;amp;dte,ddmmyyyyn8.),yymonn7.);&lt;BR /&gt;%put &amp;amp;dte_9;&lt;BR /&gt;7072017&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when I use yymonn7. as the format for the %sysfunc&amp;nbsp;I get "7072017"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when I change the format to yymmn6. I get Jibberish.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let dte = 07072017;&lt;BR /&gt;%let dte_9 = %sysfunc(inputn(&amp;amp;dte,ddmmyyyyn8.),yymmn6.);&lt;BR /&gt;%put &amp;amp;dte_9;&lt;BR /&gt;******&lt;/P&gt;&lt;P&gt;Why is the date outputted as * ? What can I do to get the date of "201707" ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 00:30:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Macro-Date-to-yymmn6-format/m-p/373464#M276205</guid>
      <dc:creator>danshek</dc:creator>
      <dc:date>2017-07-06T00:30:04Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Macro Date to yymmn6. format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Macro-Date-to-yymmn6-format/m-p/373473#M276206</link>
      <description>&lt;P&gt;Have you tried it the easy (but untested) way?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let dte&amp;nbsp;= 07072017;&lt;/P&gt;
&lt;P&gt;%let dte_9 = %substr(&amp;amp;dte, 3, 6);&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 01:17:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Macro-Date-to-yymmn6-format/m-p/373473#M276206</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-06T01:17:05Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Macro Date to yymmn6. format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Macro-Date-to-yymmn6-format/m-p/373477#M276207</link>
      <description>&lt;P&gt;I tried&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let dte_9 = %substr(&amp;amp;dte,3,6);&lt;BR /&gt;%put &amp;amp;dte_9;&lt;BR /&gt;072017&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which seems to work, but the date format is "072017".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I then transform it to YYYYMM as "201707"?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let dte_10 = %sysfunc(inputn(&amp;amp;dte_9,mmyyn6.),yymonn6.);&lt;BR /&gt;%put &amp;amp;dte_10;&lt;BR /&gt;72017&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the leading zero is gone and the date format is mYYYY.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 01:30:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Macro-Date-to-yymmn6-format/m-p/373477#M276207</guid>
      <dc:creator>danshek</dc:creator>
      <dc:date>2017-07-06T01:30:49Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Macro Date to yymmn6. format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Macro-Date-to-yymmn6-format/m-p/373479#M276208</link>
      <description>&lt;P&gt;OK, take two pieces of it then:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let dte&amp;nbsp;= 07072017;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%let dte_9 = %substr(&amp;amp;dte, 5, 4)%substr(&amp;amp;dte, 3, 2);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just don't add a space before the second instance of %SUBSTR.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 01:38:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Macro-Date-to-yymmn6-format/m-p/373479#M276208</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-06T01:38:47Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Macro Date to yymmn6. format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Macro-Date-to-yymmn6-format/m-p/373484#M276209</link>
      <description>&lt;P&gt;First, your input format (ddmmyyyyn8.) is wrong.&amp;nbsp; The statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let x=%sysfunc(inputn(07072017,ddmmyyyyn8.));&lt;/P&gt;
&lt;P&gt;produces the message&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WARNING: Argument 2 to function INPUTN referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;correct the informat to DDMMYY8..&lt;/LI&gt;
&lt;LI&gt;correct the output format to YYMMDDN8.&lt;/LI&gt;
&lt;LI&gt;Then take only the first 6 resulting characters&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;%let&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt; dte_9=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;%substr&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;(&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;(inputn(&amp;amp;dte,ddmmyy8.),yymmddn8.),1,6);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Sasfont"&gt;%put&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt; &amp;amp;=dte_9; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that the YYMON format issue an abbreviated month NAME, not month NUMBER.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 01:49:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Macro-Date-to-yymmn6-format/m-p/373484#M276209</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-07-06T01:49:54Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Macro Date to yymmn6. format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Macro-Date-to-yymmn6-format/m-p/373504#M276210</link>
      <description>&lt;P&gt;Thanks mkeintz &amp;amp; Astounding,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Much appreciated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 03:38:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Macro-Date-to-yymmn6-format/m-p/373504#M276210</guid>
      <dc:creator>danshek</dc:creator>
      <dc:date>2017-07-06T03:38:38Z</dc:date>
    </item>
  </channel>
</rss>

