<?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 Create a data set with char dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-with-char-dates/m-p/489974#M128065</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;User define 2 &amp;nbsp;macro varaibles: Current month (YYMM format) and number of months.&lt;/P&gt;&lt;P&gt;For example :&lt;/P&gt;&lt;P&gt;%let end=1808;&lt;/P&gt;&lt;P&gt;%let n=24;&lt;/P&gt;&lt;P&gt;The task is to create a data set that will have one column called :YYMM and will have the values (char values):&lt;/P&gt;&lt;P&gt;1808&lt;/P&gt;&lt;P&gt;1807&lt;/P&gt;&lt;P&gt;1806&lt;/P&gt;&lt;P&gt;.......&lt;/P&gt;&lt;P&gt;........&lt;/P&gt;&lt;P&gt;........&lt;/P&gt;&lt;P&gt;1608 (because it 24 months &amp;nbsp;back)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Aug 2018 06:35:03 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2018-08-27T06:35:03Z</dc:date>
    <item>
      <title>Create a data set with char dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-with-char-dates/m-p/489974#M128065</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;User define 2 &amp;nbsp;macro varaibles: Current month (YYMM format) and number of months.&lt;/P&gt;&lt;P&gt;For example :&lt;/P&gt;&lt;P&gt;%let end=1808;&lt;/P&gt;&lt;P&gt;%let n=24;&lt;/P&gt;&lt;P&gt;The task is to create a data set that will have one column called :YYMM and will have the values (char values):&lt;/P&gt;&lt;P&gt;1808&lt;/P&gt;&lt;P&gt;1807&lt;/P&gt;&lt;P&gt;1806&lt;/P&gt;&lt;P&gt;.......&lt;/P&gt;&lt;P&gt;........&lt;/P&gt;&lt;P&gt;........&lt;/P&gt;&lt;P&gt;1608 (because it 24 months &amp;nbsp;back)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Aug 2018 06:35:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-with-char-dates/m-p/489974#M128065</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-08-27T06:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: Create a data set with char dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-with-char-dates/m-p/489978#M128067</link>
      <description>&lt;P&gt;Seems to be related to&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Find-last-month-of-previous-qurater/m-p/489176" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Find-last-month-of-previous-qurater/m-p/489176&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/create-date-parameters/m-p/489183" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/create-date-parameters/m-p/489183&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;many more posts with similar data&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;The solution seems to be in &lt;A href="https://communities.sas.com/t5/SAS-Programming/create-date-parameters/m-p/489156" target="_self"&gt;Create date parameters&lt;/A&gt; already. Use the datastep suggested by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;, create a dataset instead of macro-variables.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Aug 2018 07:07:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-with-char-dates/m-p/489978#M128067</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-08-27T07:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: Create a data set with char dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-with-char-dates/m-p/489979#M128068</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let end=1808;
%let n=24;

data have;
do i=0 to &amp;amp;n by 1;
do yymm=intnx('month',input(cats(&amp;amp;end,'01'),yymmdd6.),-i);
format yymm yymmn4.;
output;
end;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Aug 2018 07:11:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-with-char-dates/m-p/489979#M128068</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2018-08-27T07:11:59Z</dc:date>
    </item>
    <item>
      <title>Re: Create a data set with char dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-with-char-dates/m-p/489989#M128071</link>
      <description>&lt;P&gt;Good solution:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let end=1808;&lt;BR /&gt;%let n=24;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data dates_tbl;&lt;BR /&gt;do i=0 to &amp;amp;n. ;&lt;BR /&gt;YYMM=MDY(substr(compress(&amp;amp;end.),3,2)*1,1,substr(compress(&amp;amp;end.),1,2)*1);&lt;BR /&gt;YYMM2=intnx('month',YYMM,-i) ;&lt;BR /&gt;YYMM2b=put(YYMM2,yymmn4.);&lt;/P&gt;&lt;P&gt;YYMM3=intnx('month',YYMM2,-12,'end') ;&lt;BR /&gt;var_name='t'||strip(&amp;amp;n.-i);&lt;BR /&gt;call symputx (var_name,YYMM3);&lt;/P&gt;&lt;P&gt;var_name2='m'||strip(&amp;amp;n.-i);&lt;BR /&gt;call symputx (var_name2,YYMM2b);&lt;/P&gt;&lt;P&gt;format YYMM YYMM2 YYMMN4. YYMM3 date9.;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;%put &amp;amp;t0;&lt;BR /&gt;%put &amp;amp;t1;&lt;BR /&gt;%put &amp;amp;t2;&lt;BR /&gt;%put &amp;amp;t24;&lt;BR /&gt;%put &amp;amp;m0;&lt;BR /&gt;%put &amp;amp;m1;&lt;BR /&gt;%put &amp;amp;m2;&lt;BR /&gt;%put &amp;amp;m24;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Aug 2018 07:42:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-with-char-dates/m-p/489989#M128071</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-08-27T07:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: Create a data set with char dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-with-char-dates/m-p/489996#M128076</link>
      <description>&lt;P&gt;I see that your code is working well but why do you have to Do loops?&lt;/P&gt;&lt;P&gt;Is it not better to &amp;nbsp;have one Do loop?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let end=1808;
%let n=24;
data have;
do i=0 to &amp;amp;n by 1;
yymm=intnx('month',input(cats(&amp;amp;end,'01'),yymmdd6.),-i);
format yymm yymmn4.;
output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Aug 2018 08:08:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-with-char-dates/m-p/489996#M128076</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-08-27T08:08:49Z</dc:date>
    </item>
  </channel>
</rss>

