<?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: create date parameters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/create-date-parameters/m-p/489180#M127661</link>
    <description>&lt;P&gt;Its because you are mixing up what macro is and what Base SAS programming is.&amp;nbsp; I really cannot be bothered to go over it again.&lt;/P&gt;
&lt;PRE&gt;k=%eval(&amp;amp;i.-&amp;amp;n.);&lt;BR /&gt; t&amp;amp;i.=intnx('month',&amp;amp;end_date.,-&amp;amp;k.,'end');&lt;/PRE&gt;
&lt;P&gt;Can you not see the issue from these two lines?&amp;nbsp; Start by do it all in Base SAS - this is the programming language.&amp;nbsp; There is no benefit, or need to keep pushing all your coding into Macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Aug 2018 09:38:20 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-08-23T09:38:20Z</dc:date>
    <item>
      <title>create date parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-date-parameters/m-p/489156#M127641</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;User define current month (1808) &amp;nbsp;and number of months back (12).&lt;/P&gt;&lt;P&gt;SAS should create parameters:&lt;/P&gt;&lt;P&gt;m24=1808&lt;/P&gt;&lt;P&gt;m23=1807&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;m1=1709&lt;/P&gt;&lt;P&gt;m0=1708&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get an error in my code.&lt;/P&gt;&lt;P&gt;I want to repair&amp;nbsp;my code please&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let end=1808;
%let n=12;
%let end_date=%sysfunc(inputn(&amp;amp;end.,yymmn4.));
%put &amp;amp;end_date.;


%macro months;
%do i=&amp;amp;n. %to i=0 %by -1 ;
k=%eval(&amp;amp;i.-&amp;amp;n.);
	t&amp;amp;i.=intnx('month',&amp;amp;end_date.,-&amp;amp;k.,'end');
	call symput("t&amp;amp;i",t&amp;amp;i.);
%end;
%mend;


data month_score1(drop=k);
%months;
run;


%macro mon;
%do i=&amp;amp;n. %to i=0 %by -1;
k=%eval(&amp;amp;i.-&amp;amp;n.);
	m&amp;amp;i.=put(&amp;amp;&amp;amp;t&amp;amp;i.,yymmn5.);
	call symput("m&amp;amp;i",trim(left(m&amp;amp;i.)));
%end;
%mend;  
data  month_score2 (drop=k);
%mon;
run;
%put &amp;amp;m0.;
%put &amp;amp;&amp;amp;m&amp;amp;n..;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Aug 2018 08:17:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-date-parameters/m-p/489156#M127641</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-08-23T08:17:38Z</dc:date>
    </item>
    <item>
      <title>Re: create date parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-date-parameters/m-p/489158#M127643</link>
      <description>&lt;P&gt;Why?&amp;nbsp; Putting date information into macro variables is really not the best way forward regardless of your process.&amp;nbsp; Macro is nothing more than a&amp;nbsp;&lt;U&gt;&lt;STRONG&gt;text generation system&lt;/STRONG&gt;&lt;/U&gt;.&amp;nbsp; Do not use it to replace base SAS.&lt;/P&gt;
&lt;PRE&gt;%let end=1808;&lt;BR /&gt;%let n=12;&lt;BR /&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt; end=input(cats("20","&amp;amp;end.","01"),yymmdd10.);&lt;BR /&gt; j=0;&lt;BR /&gt; do i=0 to -&amp;amp;n. by -1;&lt;BR /&gt;  call symputx(cats("m",put(j,best.)),put(intnx('month',end,i),yymmn4.));&lt;BR /&gt;  j=j+1;&lt;BR /&gt; end;&lt;BR /&gt;run;&lt;BR /&gt;&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;m3.;&lt;BR /&gt;%put &amp;amp;m4.;&lt;BR /&gt;%put &amp;amp;m5.;
&lt;/PRE&gt;
&lt;P&gt;See the above example, and compare it to the mess of macro you have created,&amp;nbsp;&lt;U&gt;&lt;STRONG&gt;Base SAS is the programming language&lt;/STRONG&gt;&lt;/U&gt;, use it.&amp;nbsp; Although I wouldn't even be doing this in the first place as you have a formula and a base point so there&amp;nbsp;&lt;U&gt;&lt;STRONG&gt;is no value creating macro variables for each item.&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Aug 2018 08:34:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-date-parameters/m-p/489158#M127643</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-23T08:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: create date parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-date-parameters/m-p/489163#M127648</link>
      <description>&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;I run your code but: m12 should be &amp;nbsp;1808 &amp;nbsp;and in your code m0 is 1808&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, 23 Aug 2018 08:47:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-date-parameters/m-p/489163#M127648</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-08-23T08:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: create date parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-date-parameters/m-p/489166#M127651</link>
      <description>&lt;P&gt;Change:&lt;/P&gt;
&lt;PRE&gt; j=12;&lt;BR /&gt; do i=0 to -&amp;amp;n. by -1;&lt;BR /&gt;  call symputx(cats("m",put(j,best.)),put(intnx('month',end,i),yymmn4.));&lt;BR /&gt;  j=j-1;&lt;BR /&gt; end;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Aug 2018 08:49:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-date-parameters/m-p/489166#M127651</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-23T08:49:46Z</dc:date>
    </item>
    <item>
      <title>Re: create date parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-date-parameters/m-p/489179#M127660</link>
      <description>&lt;P&gt;Perfect and thank you!&lt;/P&gt;&lt;P&gt;May you please look again in my code and tell me specific what is wrong here?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let end=1808;
%let n=12;
%let end_date=%sysfunc(inputn(&amp;amp;end.,yymmn4.));
%put &amp;amp;end_date.;


%macro months;
%do i=&amp;amp;n. %to i=0 %by -1 ;
k=%eval(&amp;amp;i.-&amp;amp;n.);
	t&amp;amp;i.=intnx('month',&amp;amp;end_date.,-&amp;amp;k.,'end');
	call symput("t&amp;amp;i",t&amp;amp;i.);
%end;
%mend;


data month_score1(drop=k);
%months;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Aug 2018 09:33:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-date-parameters/m-p/489179#M127660</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-08-23T09:33:17Z</dc:date>
    </item>
    <item>
      <title>Re: create date parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-date-parameters/m-p/489180#M127661</link>
      <description>&lt;P&gt;Its because you are mixing up what macro is and what Base SAS programming is.&amp;nbsp; I really cannot be bothered to go over it again.&lt;/P&gt;
&lt;PRE&gt;k=%eval(&amp;amp;i.-&amp;amp;n.);&lt;BR /&gt; t&amp;amp;i.=intnx('month',&amp;amp;end_date.,-&amp;amp;k.,'end');&lt;/PRE&gt;
&lt;P&gt;Can you not see the issue from these two lines?&amp;nbsp; Start by do it all in Base SAS - this is the programming language.&amp;nbsp; There is no benefit, or need to keep pushing all your coding into Macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Aug 2018 09:38:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-date-parameters/m-p/489180#M127661</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-23T09:38:20Z</dc:date>
    </item>
    <item>
      <title>Re: create date parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-date-parameters/m-p/489183#M127662</link>
      <description>&lt;P&gt;This is also working very well.&lt;/P&gt;&lt;P&gt;The problem was that I need to define k as parameter with %let&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;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let end=1808;
%let n=12;
%let end_date=%sysfunc(inputn(&amp;amp;end.,yymmn4.));
%put &amp;amp;end_date.;


%macro months;
%do i=&amp;amp;n. %to i=0 %by -1 ;
%let k=%eval(&amp;amp;i.-&amp;amp;n.);
	t&amp;amp;i.=intnx('month',&amp;amp;end_date.,&amp;amp;k.,'end');
	call symput("t&amp;amp;i",t&amp;amp;i.);
%end;
%mend;


data month_score1;
%months;
run;


%macro mon;
%do i=&amp;amp;n. %to i=0 %by -1;
%let k=%eval(&amp;amp;i.-&amp;amp;n.);
	m&amp;amp;i.=put(&amp;amp;&amp;amp;t&amp;amp;i.,yymmn5.);
	call symput("m&amp;amp;i",trim(left(m&amp;amp;i.)));
%end;
%mend;  
data  month_score2 ;
%mon;
run;
%put &amp;amp;m0.;
%put &amp;amp;&amp;amp;m&amp;amp;n..;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Aug 2018 10:12:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-date-parameters/m-p/489183#M127662</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-08-23T10:12:00Z</dc:date>
    </item>
  </channel>
</rss>

