<?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: Loop values into macro parameters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Loop-values-into-macro-parameters/m-p/629600#M186219</link>
    <description>&lt;P&gt;Please show us a representative portion of MEMLIST.&lt;/P&gt;</description>
    <pubDate>Wed, 04 Mar 2020 20:34:44 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-03-04T20:34:44Z</dc:date>
    <item>
      <title>Loop values into macro parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-values-into-macro-parameters/m-p/629596#M186216</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is a follow on to a previous question I had (&lt;A href="https://communities.sas.com/t5/SAS-Programming/Loop-through-observations-and-extract-contents/m-p/626542" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/Loop-through-observations-and-extract-contents/m-p/626542&lt;/A&gt;). I appreciate all the help thus far. I am almost to where I need to be.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to increment through dates within the macro statements below. Instead of:&amp;nbsp;&amp;nbsp;&lt;FONT color="#0000FF"&gt;source=NSDQsh201101.zip,&amp;nbsp;&lt;FONT color="#000000"&gt;I would like to write something like:&amp;nbsp;&amp;nbsp;&lt;FONT color="#008000"&gt;source=MSDQsh&amp;amp;year&amp;amp;month.&amp;nbsp;&amp;nbsp;&lt;FONT color="#000000"&gt;And instead of &lt;FONT color="#0000FF"&gt;outds=nasdaq.NSDQsh201101 &lt;FONT color="#000000"&gt;at the bottom&lt;/FONT&gt;,&amp;nbsp;&lt;FONT color="#000000"&gt;I would like write &lt;FONT color="#008080"&gt;outds=nasdaq.NSDQsh&amp;amp;year&amp;amp;month&lt;/FONT&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;FONT color="#000000"&gt;&lt;FONT color="#008000"&gt;&lt;FONT color="#000000"&gt;&lt;FONT color="#0000FF"&gt;&lt;FONT color="#000000"&gt;And then have something like:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;FONT color="#000000"&gt;&lt;FONT color="#008000"&gt;&lt;FONT color="#000000"&gt;&lt;FONT color="#0000FF"&gt;&lt;FONT color="#000000"&gt;%do year=2010 to 2020&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;FONT color="#000000"&gt;&lt;FONT color="#008000"&gt;&lt;FONT color="#000000"&gt;&lt;FONT color="#0000FF"&gt;&lt;FONT color="#000000"&gt;%do month=01 to 12&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;FONT color="#000000"&gt;&lt;FONT color="#008000"&gt;&lt;FONT color="#000000"&gt;&lt;FONT color="#0000FF"&gt;&lt;FONT color="#000000"&gt;How could i do this? Would I need to wrap all of the statements below under a macro that does the date incrementing?&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&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;%zipMemList(source=&lt;FONT size="5"&gt;NSDQsh201101.zip&lt;/FONT&gt;, outds=memlist);
&lt;BR /&gt;
/* execute macro %ReadMemInZip() once per member in zip file */
data _null_;
  set memlist;
  cmd=cats('%ReadMemInZip(source=',zip,', member=',memname,', outds=want)');
  call execute(cmd);
run;


/*Aggregate transaction level data to daily*/
%convertdaily(source=want, outds=nasdaq.&lt;FONT size="5"&gt;NSDQsh201101&lt;/FONT&gt;);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Mar 2020 20:40:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-values-into-macro-parameters/m-p/629596#M186216</guid>
      <dc:creator>AdamMadison</dc:creator>
      <dc:date>2020-03-04T20:40:55Z</dc:date>
    </item>
    <item>
      <title>Re: Loop values into macro parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-values-into-macro-parameters/m-p/629600#M186219</link>
      <description>&lt;P&gt;Please show us a representative portion of MEMLIST.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Mar 2020 20:34:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-values-into-macro-parameters/m-p/629600#M186219</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-04T20:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: Loop values into macro parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-values-into-macro-parameters/m-p/629601#M186220</link>
      <description>&lt;P&gt;Why are you asking about looping in macro code when you are running data step code?&lt;/P&gt;
&lt;P&gt;Either way looping over DATE values instead of separate YEAR/MONTH values will be much easier, especially if you want to go across year boundaries, from September to March for example.&lt;/P&gt;
&lt;P&gt;For example here is a data step that generates one call per month from september 2019 to march 2020.&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;data _null_;
  start='01SEP2019'd ;
  end='01MAR2020'd;
  do offset = 0 to intck('month',start,end);
    date=intnx('month',start,offset);
    length memname $32 cmd $200;
    memname = cats('NSDQsh',put(date,yymmn6.));
    source = cats('MSDQsh',put(date,yymmn6.));
    cmd=cats('%nrstr(%ReadMemInZip)(source=',source,',outds=nasdaq.',member,')');
    call execute(cmd);
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Mar 2020 20:35:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-values-into-macro-parameters/m-p/629601#M186220</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-04T20:35:41Z</dc:date>
    </item>
    <item>
      <title>Re: Loop values into macro parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-values-into-macro-parameters/m-p/629602#M186221</link>
      <description>&lt;P&gt;The "dates" are actually just file names organized by date (year/month), not true dates. So I am trying to process "NSDQsh&lt;FONT color="#008000"&gt;201101&lt;/FONT&gt;.zip" through the statements in the post and the final output will be "nasdaq.NSDQsh&lt;FONT color="#008000"&gt;201101&lt;/FONT&gt;".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I want to do the same process to "NSDQsh&lt;FONT color="#993300"&gt;201102&lt;/FONT&gt;.zip" and output nasdaq.NSDQ&lt;FONT color="#993300"&gt;201102&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#993300"&gt;&lt;FONT color="#000000"&gt;Then I want to do the same process to&lt;/FONT&gt; &lt;FONT color="#000000"&gt;"NSDQsh&lt;FONT color="#993300"&gt;2011&lt;/FONT&gt;&lt;/FONT&gt;03.zip" &lt;FONT color="#000000"&gt;and output&lt;/FONT&gt; &lt;FONT color="#000000"&gt;nasdaq.NSDQ&lt;/FONT&gt;201103&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Mar 2020 20:45:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-values-into-macro-parameters/m-p/629602#M186221</guid>
      <dc:creator>AdamMadison</dc:creator>
      <dc:date>2020-03-04T20:45:11Z</dc:date>
    </item>
  </channel>
</rss>

