<?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: DO with %let in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/DO-with-let/m-p/791529#M253549</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
	do i=1 to 20;
		date=intnx('qtr', today(), -i, 'e');
		date_char=put(date, date9.);
		call execute (catt('data new_c', 
		                    date_char, 
		                    '; format dat date9.; dat=', 
			                date, 
			                ';run;')
			          );
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Does last 20 quarters fully dynamically.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;OTE: CALL EXECUTE generated line.
 1         + data new_c31DEC2021; format dat date9.; dat=22645;run;
 
 NOTE: The data set WORK.NEW_C31DEC2021 has 1 observations and 1 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              516.90k
       OS Memory           25764.00k
       Timestamp           01/21/2022 05:33:54 PM
       Step Count                        63  Switch Count  2
       Page Faults                       0
       Page Reclaims                     94
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 2         + data new_c30SEP2021; format dat date9.; dat=22553;run;
 
 NOTE: The data set WORK.NEW_C30SEP2021 has 1 observations and 1 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              516.90k
       OS Memory           25764.00k
       Timestamp           01/21/2022 05:33:54 PM
       Step Count                        64  Switch Count  2
       Page Faults                       0
       Page Reclaims                     88
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 3         + data new_c30JUN2021; format dat date9.; dat=22461;run;
 
 NOTE: The data set WORK.NEW_C30JUN2021 has 1 observations and 1 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              516.90k
       OS Memory           25764.00k
       Timestamp           01/21/2022 05:33:54 PM
       Step Count                        65  Switch Count  2
       Page Faults                       0
       Page Reclaims                     88
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 4         + data new_c31MAR2021; format dat date9.; dat=22370;run;
 
 NOTE: The data set WORK.NEW_C31MAR2021 has 1 observations and 1 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              516.90k
       OS Memory           25764.00k
       Timestamp           01/21/2022 05:33:54 PM
       Step Count                        66  Switch Count  2
       Page Faults                       0
       Page Reclaims                     88
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 5         + data new_c31DEC2020; format dat date9.; dat=22280;run;
 
 NOTE: The data set WORK.NEW_C31DEC2020 has 1 observations and 1 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              516.90k
       OS Memory           25764.00k
       Timestamp           01/21/2022 05:33:54 PM
       Step Count                        67  Switch Count  2
       Page Faults                       0
       Page Reclaims                     88
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 6         + data new_c30SEP2020; format dat date9.; dat=22188;run;
 &lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Reeza_0-1642786680312.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67608i317AC495EC726D0A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Reeza_0-1642786680312.png" alt="Reeza_0-1642786680312.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Jan 2022 17:38:06 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2022-01-21T17:38:06Z</dc:date>
    <item>
      <title>DO with %let</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-with-let/m-p/791491#M253531</link>
      <description>&lt;P&gt;Hello, I want to make a loop with this code, I have many dates just put 2 dates below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let cdate=31oct2020;&lt;BR /&gt;%put &amp;amp;cdate;&lt;/P&gt;&lt;P&gt;data new_&amp;amp;cdate.;&lt;BR /&gt;format dat date9.;&lt;BR /&gt;dat="&amp;amp;cdate"d;&lt;BR /&gt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%let cdate=31jan2021 ;&lt;BR /&gt;%put &amp;amp;cdate;&lt;/P&gt;&lt;P&gt;data new_&amp;amp;cdate.;&lt;BR /&gt;format dat date9.;&lt;BR /&gt;dat="&amp;amp;cdate"d;&lt;BR /&gt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your hepl&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2022 16:36:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-with-let/m-p/791491#M253531</guid>
      <dc:creator>ssafmed</dc:creator>
      <dc:date>2022-01-21T16:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: DO with %let</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-with-let/m-p/791495#M253534</link>
      <description>&lt;P&gt;This is splitting data into subsets. Can you explain why you're doing this? It's typically not recommended. &lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;How are your multiple dates stored? In a macro variable or data set or derived logically (ie current month).&lt;/STRONG&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2022 16:52:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-with-let/m-p/791495#M253534</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-01-21T16:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: DO with %let</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-with-let/m-p/791497#M253535</link>
      <description>&lt;P&gt;use do loop construct and the magical intck and intnx functions for that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;like reeza said, it seems that you're trying to create as many data sets as days in the range of the 2 dates. I've interpreted that you'd like to create a series of dates each corresponding to one row.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let cdate='31oct2020'd;
%put &amp;amp;cdate;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="a1.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67602i7EA992053F90CD7A/image-size/large?v=v2&amp;amp;px=999" role="button" title="a1.png" alt="a1.png" /&gt;&lt;/span&gt;

data temp;
format dat date9.;
do i=1 to intck('days', &amp;amp;cdate, '31jan2021'd) ;
dat=intnx('days', &amp;amp;cdate, i);
output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2022 16:48:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-with-let/m-p/791497#M253535</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2022-01-21T16:48:55Z</dc:date>
    </item>
    <item>
      <title>Re: DO with %let</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-with-let/m-p/791499#M253536</link>
      <description>&lt;P&gt;Thanks but I have 20 different dates!&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2022 16:48:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-with-let/m-p/791499#M253536</guid>
      <dc:creator>ssafmed</dc:creator>
      <dc:date>2022-01-21T16:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: DO with %let</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-with-let/m-p/791502#M253537</link>
      <description>&lt;P&gt;I have a code that I want to exceute for 20 dates and then store it in differents 20 output dataset!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2022 16:50:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-with-let/m-p/791502#M253537</guid>
      <dc:creator>ssafmed</dc:creator>
      <dc:date>2022-01-21T16:50:42Z</dc:date>
    </item>
    <item>
      <title>Re: DO with %let</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-with-let/m-p/791503#M253538</link>
      <description>&lt;P&gt;If you can't provide any more information for whatever reason, see this tutorial on how to convert a working program to a macro and run it for a series of parameters stored in a data set.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;Tutorial on converting a working program to a macro&lt;BR /&gt;This method is pretty robust and helps prevent errors and makes it much easier to debug your code. Obviously biased, because I wrote it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;A href="https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md" target="_blank"&gt;https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2022 16:51:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-with-let/m-p/791503#M253538</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-01-21T16:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: DO with %let</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-with-let/m-p/791504#M253539</link>
      <description>&lt;P&gt;What does that mean?&lt;/P&gt;
&lt;P&gt;20 dates from where?&amp;nbsp; Are you planning to type them in?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dates;
do date='01JAN2020'd,'05MAR2020'd;
   output;
end;
  format date date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or read them from some dataset:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table dates as 
select distinct date 
  from have
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or is there some pattern to the dates so that you can generate 20 new dates from some starting point?&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2022 16:54:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-with-let/m-p/791504#M253539</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-01-21T16:54:51Z</dc:date>
    </item>
    <item>
      <title>Re: DO with %let</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-with-let/m-p/791505#M253540</link>
      <description>&lt;P&gt;Yes but I want the output to be like :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;new_31oct2020&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;new_31jan2021&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;new_31mar2021&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;....&lt;/SPAN&gt;&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2022 16:59:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-with-let/m-p/791505#M253540</guid>
      <dc:creator>ssafmed</dc:creator>
      <dc:date>2022-01-21T16:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: DO with %let</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-with-let/m-p/791506#M253541</link>
      <description>Coffee or tea?&lt;BR /&gt;Yes.......&lt;BR /&gt;&lt;BR /&gt;There's an OR there - so which is the correct option that Tom presented?&lt;BR /&gt;</description>
      <pubDate>Fri, 21 Jan 2022 17:03:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-with-let/m-p/791506#M253541</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-01-21T17:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: DO with %let</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-with-let/m-p/791512#M253544</link>
      <description>&lt;P&gt;I have lost the thread of what the question is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to do the same thing over a list of values then in MACRO code the easiest way is to put the list of values into a macro variable.&amp;nbsp; Since your example appear to not allow spaces in the values then use a space delimited list.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dates=31oct2020 31jan2021 31mar2021;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now if you want to use that list inside a macro definition (where you can have macro logic) then it is simple.&amp;nbsp; So here is an simple contrived example.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro mymacro(dates);
%local index date dsname ;
%do index=1 %to %sysfunc(countw(&amp;amp;dates,%str( )));
  %let date=%scan(&amp;amp;dates,&amp;amp;index,%str( ));
   %let dsname=new_&amp;amp;date;
   data &amp;amp;dsname;
      set have;
      where datevar = "&amp;amp;date"d ;
   run;
%end;
%mend mymacro;

%mymacro(dates=31oct2020 31jan2021 31mar2021)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Jan 2022 17:20:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-with-let/m-p/791512#M253544</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-01-21T17:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: DO with %let</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-with-let/m-p/791529#M253549</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
	do i=1 to 20;
		date=intnx('qtr', today(), -i, 'e');
		date_char=put(date, date9.);
		call execute (catt('data new_c', 
		                    date_char, 
		                    '; format dat date9.; dat=', 
			                date, 
			                ';run;')
			          );
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Does last 20 quarters fully dynamically.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;OTE: CALL EXECUTE generated line.
 1         + data new_c31DEC2021; format dat date9.; dat=22645;run;
 
 NOTE: The data set WORK.NEW_C31DEC2021 has 1 observations and 1 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              516.90k
       OS Memory           25764.00k
       Timestamp           01/21/2022 05:33:54 PM
       Step Count                        63  Switch Count  2
       Page Faults                       0
       Page Reclaims                     94
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 2         + data new_c30SEP2021; format dat date9.; dat=22553;run;
 
 NOTE: The data set WORK.NEW_C30SEP2021 has 1 observations and 1 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              516.90k
       OS Memory           25764.00k
       Timestamp           01/21/2022 05:33:54 PM
       Step Count                        64  Switch Count  2
       Page Faults                       0
       Page Reclaims                     88
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 3         + data new_c30JUN2021; format dat date9.; dat=22461;run;
 
 NOTE: The data set WORK.NEW_C30JUN2021 has 1 observations and 1 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              516.90k
       OS Memory           25764.00k
       Timestamp           01/21/2022 05:33:54 PM
       Step Count                        65  Switch Count  2
       Page Faults                       0
       Page Reclaims                     88
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 4         + data new_c31MAR2021; format dat date9.; dat=22370;run;
 
 NOTE: The data set WORK.NEW_C31MAR2021 has 1 observations and 1 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              516.90k
       OS Memory           25764.00k
       Timestamp           01/21/2022 05:33:54 PM
       Step Count                        66  Switch Count  2
       Page Faults                       0
       Page Reclaims                     88
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 5         + data new_c31DEC2020; format dat date9.; dat=22280;run;
 
 NOTE: The data set WORK.NEW_C31DEC2020 has 1 observations and 1 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              516.90k
       OS Memory           25764.00k
       Timestamp           01/21/2022 05:33:54 PM
       Step Count                        67  Switch Count  2
       Page Faults                       0
       Page Reclaims                     88
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 6         + data new_c30SEP2020; format dat date9.; dat=22188;run;
 &lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Reeza_0-1642786680312.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67608i317AC495EC726D0A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Reeza_0-1642786680312.png" alt="Reeza_0-1642786680312.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2022 17:38:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-with-let/m-p/791529#M253549</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-01-21T17:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: DO with %let</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-with-let/m-p/791550#M253560</link>
      <description>Thanks a lot!</description>
      <pubDate>Fri, 21 Jan 2022 18:16:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-with-let/m-p/791550#M253560</guid>
      <dc:creator>ssafmed</dc:creator>
      <dc:date>2022-01-21T18:16:20Z</dc:date>
    </item>
  </channel>
</rss>

