<?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 loop - when parameter values not consecutive in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/do-loop-when-parameter-values-not-consecutive/m-p/106978#M29801</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or Call execute() function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data amount0203;set sashelp.class;amount=1;run;
data amount1112;set sashelp.class;amount=2;run;

data _null_;
 set sashelp.vmember(keep=memname libname where=(libname='WORK' and memname like 'AMOUNT%'));
 call execute('proc means data='||strip(memname)||' nway noprint;var amount; class sex; output out=out20'||substr(memname,7,2)||' (drop=_type_ _freq_) sum=;run;');
run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 16 Jul 2012 02:02:26 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2012-07-16T02:02:26Z</dc:date>
    <item>
      <title>%do loop - when parameter values not consecutive</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/do-loop-when-parameter-values-not-consecutive/m-p/106975#M29798</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd like to use %do year=2002&amp;nbsp; %to year=2011 for the 10 years of data I'd like to run, however, my source data is not 4 digits or even 2 digits, but like 0203, 0304, 0405 ...1112. How can I get around with it if I still want to use %do loop?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; If I don't use %do %to:&lt;/P&gt;&lt;P&gt;proc means data=amount0203 nway noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var amount; class sex;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output out=out2002 (drop=_type_ _freq_) sum=;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;proc means data=amount1112 nway noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var amount; class sex;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output out=out2011 (drop=_type_ _freq_) sum=;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was hoping to use %do YEAR=2001 %to 2011, but how do I get around with the nonconsecutive part of the dataset name while using %do loop?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro year();&lt;/P&gt;&lt;P&gt;%do YEAR=2002 %to 2011;&lt;/P&gt;&lt;P&gt;proc means data=amount***1112*** nway noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var amount; class sex;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output out=out&amp;amp;YEAR (drop=_type_ _freq_) sum=;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend year;&lt;/P&gt;&lt;P&gt;%year;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Jul 2012 16:23:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/do-loop-when-parameter-values-not-consecutive/m-p/106975#M29798</guid>
      <dc:creator>Solph</dc:creator>
      <dc:date>2012-07-13T16:23:15Z</dc:date>
    </item>
    <item>
      <title>Re: %do loop - when parameter values not consecutive</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/do-loop-when-parameter-values-not-consecutive/m-p/106976#M29799</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this instead of year use the last 2 digits. Since macro do loops currently don't do non-integer values...&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%do i = 2 %to 11; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %let first = %sysfunc(putn(&amp;amp;i,z2.)); &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %let second= %sysfunc(putn(%eval(&amp;amp;i+1),z2.)); &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %let ystr= &amp;amp;first.&amp;amp;second; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* put your analysis here using &amp;amp;ystr in your amount data sets*/ &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* and output = out20&amp;amp;i */ &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WARNING: Solution only valid for years 2000 to 2098.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Jul 2012 16:43:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/do-loop-when-parameter-values-not-consecutive/m-p/106976#M29799</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2012-07-13T16:43:25Z</dc:date>
    </item>
    <item>
      <title>Re: %do loop - when parameter values not consecutive</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/do-loop-when-parameter-values-not-consecutive/m-p/106977#M29800</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot. It is a really neat way of doing it. Much appreciated for the code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Jul 2012 18:11:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/do-loop-when-parameter-values-not-consecutive/m-p/106977#M29800</guid>
      <dc:creator>Solph</dc:creator>
      <dc:date>2012-07-13T18:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: %do loop - when parameter values not consecutive</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/do-loop-when-parameter-values-not-consecutive/m-p/106978#M29801</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or Call execute() function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data amount0203;set sashelp.class;amount=1;run;
data amount1112;set sashelp.class;amount=2;run;

data _null_;
 set sashelp.vmember(keep=memname libname where=(libname='WORK' and memname like 'AMOUNT%'));
 call execute('proc means data='||strip(memname)||' nway noprint;var amount; class sex; output out=out20'||substr(memname,7,2)||' (drop=_type_ _freq_) sum=;run;');
run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jul 2012 02:02:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/do-loop-when-parameter-values-not-consecutive/m-p/106978#M29801</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-07-16T02:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: %do loop - when parameter values not consecutive</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/do-loop-when-parameter-values-not-consecutive/m-p/106979#M29802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yet another approach, which works with any list of delimited tokens:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: #A0C0FF;"&gt;%macro&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; &lt;STRONG&gt;&lt;EM&gt;debug&lt;/EM&gt;&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%put&lt;/STRONG&gt; &lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%scan&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;(&amp;amp;word,1,|);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%put&lt;/STRONG&gt; &lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%scan&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;(&amp;amp;word,2,|);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%put&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: #A0C0FF;"&gt;%mend&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: #A0C0FF;"&gt;%macro&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; &lt;STRONG&gt;&lt;EM&gt;means&lt;/EM&gt;&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;&amp;nbsp; proc means data=amount&lt;/SPAN&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%scan&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;(&amp;amp;word,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: blue; background: white;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;,|) nway noprint;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var amount; class sex;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output out=out&lt;/SPAN&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%scan&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;(&amp;amp;word,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: blue; background: white;"&gt;2&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;,|) (drop=_type_ _freq_) sum=;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: #A0C0FF;"&gt;%mend&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: #A0C0FF;"&gt;%macro&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; &lt;STRONG&gt;&lt;EM&gt;build_list&lt;/EM&gt;&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%global&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; list;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%do&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; i=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: blue; background: white;"&gt;2&lt;/SPAN&gt; &lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%to&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: blue; background: white;"&gt;12&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%let&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; j=&lt;/SPAN&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%eval&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;(&amp;amp;i+1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%if&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; (&lt;/SPAN&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%superq&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;(list) eq ) &lt;/SPAN&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%then&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%let&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; list=&lt;/SPAN&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%sysfunc&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;(putn(&amp;amp;i,z2.))&lt;/SPAN&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%sysfunc&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;(putn(&amp;amp;j,z2))|20&lt;/SPAN&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%sysfunc&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;(putn(&amp;amp;i,z2.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%else&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%let&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; list=&amp;amp;list ^ &lt;/SPAN&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%sysfunc&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;(putn(&amp;amp;i,z2.))&lt;/SPAN&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%sysfunc&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;(putn(&amp;amp;j,z2))|20&lt;/SPAN&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%sysfunc&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;(putn(&amp;amp;i,z2.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%end&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: #A0C0FF;"&gt;%mend&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%let&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; list=;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;%&lt;STRONG&gt;&lt;EM&gt;build_list&lt;/EM&gt;&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%put&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; &amp;amp;list;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: teal; background: white;"&gt;* alternative, non-macro approach ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%let&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; list=;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;data&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: fuchsia; background: white;"&gt;_null_&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: fuchsia; background: white;"&gt;length&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; list $&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: blue; background: white;"&gt;1000&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: fuchsia; background: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; i=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: blue; background: white;"&gt;2&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: fuchsia; background: white;"&gt;to&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: blue; background: white;"&gt;12&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; list=catx(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: blue; background: white;"&gt;" ^ "&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;,list,cats(put(i,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: #0000c0; background: white;"&gt;z2.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;),put(i+&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: blue; background: white;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: #0000c0; background: white;"&gt;z2.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;),&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: blue; background: white;"&gt;"|"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: blue; background: white;"&gt;"20"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;,put(i,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: #0000c0; background: white;"&gt;z2.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;)));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: fuchsia; background: white;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: fuchsia; background: white;"&gt;call&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; symputx(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: blue; background: white;"&gt;"list"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;,list);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%put&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; &amp;amp;list;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: teal; background: white;"&gt;* test ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;%&lt;STRONG&gt;&lt;EM&gt;loop&lt;/EM&gt;&lt;/STRONG&gt;(&amp;amp;list,dlm=^,mname=debug);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: teal; background: white;"&gt;* run ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;%&lt;STRONG&gt;&lt;EM&gt;loop&lt;/EM&gt;&lt;/STRONG&gt;(&amp;amp;list,dlm=^,mname=means);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See attached loop macro...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH,&lt;/P&gt;&lt;P&gt;Scott&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jul 2012 05:13:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/do-loop-when-parameter-values-not-consecutive/m-p/106979#M29802</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2012-07-16T05:13:38Z</dc:date>
    </item>
    <item>
      <title>Re: %do loop - when parameter values not consecutive</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/do-loop-when-parameter-values-not-consecutive/m-p/106980#M29803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Note that you do no normally need %EVAL() to evaluate simple arithmetic inside of %SYSFUNC() parameter values.&amp;nbsp; The function evaluation will do that.&lt;/P&gt;&lt;P&gt;To handle century cross-overs use Z4. format and take the last two digits.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%macro xx(s,e);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; %do i = &amp;amp;s %to &amp;amp;e;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let ds=%substr(%sysfunc(putn(&amp;amp;i,z4.)),3)%substr(%sysfunc(putn(&amp;amp;i+1,z4.)),3);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put i=&amp;amp;i ds=&amp;amp;ds;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; %end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%mend;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;175&amp;nbsp; %xx(8,11);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;i=8 ds=0809&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;i=9 ds=0910&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;i=10 ds=1011&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;i=11 ds=1112&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;176&amp;nbsp; %xx(1998,2002);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;i=1998 ds=9899&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;i=1999 ds=9900&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;i=2000 ds=0001&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;i=2001 ds=0102&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;i=2002 ds=0203&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jul 2012 16:38:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/do-loop-when-parameter-values-not-consecutive/m-p/106980#M29803</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-07-16T16:38:06Z</dc:date>
    </item>
  </channel>
</rss>

