<?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: Automating this code using DO LOOP in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Automating-this-code-using-DO-LOOP/m-p/541657#M149585</link>
    <description>&lt;P&gt;When you run this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let string1 = I like;
%let string2 = Kermit;
%let string3 = the;
%let string4 = Frog;

%put &amp;amp;=string1 &amp;amp;=string2 &amp;amp;=string3 &amp;amp;=string4;


%macro attempt ;
%global allcodes allcodes2;
%let allCodes =;
%do i = 1 %TO 4;

%let allCodes = &amp;amp;allCodes &amp;amp;&amp;amp;string&amp;amp;i;

%if &amp;amp;i = 1 %then %let allcodes2 = (&amp;amp;&amp;amp;string&amp;amp;i;
%else %let allcodes2 = &amp;amp;allcodes2 &amp;amp;&amp;amp;string&amp;amp;i;

%end;
%let allcodes2 = &amp;amp;allcodes2)%str(;);


%put &amp;amp;=allCodes &amp;amp;=allcodes2;

%mend attempt;

%attempt&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then &amp;amp;allcodes should have all 4 strings and allcodes2 should have parens and a semi-colon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
    <pubDate>Fri, 08 Mar 2019 23:29:57 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2019-03-08T23:29:57Z</dc:date>
    <item>
      <title>Automating this code using DO LOOP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automating-this-code-using-DO-LOOP/m-p/541640#M149572</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure why but I am unable to automate this portion:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro title();&lt;/P&gt;&lt;P&gt;%let allCodes = %sysfunc(CATX(",", &amp;amp;Codes1, &amp;amp;Codes2, &amp;amp;Codes3, &amp;amp;Codes4 ));&lt;/P&gt;&lt;P&gt;%put &amp;amp;allCodes;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%title();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am doing this below for automating the above %let allCodes statement - but seeing errors:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro attempt1();&lt;/P&gt;&lt;P&gt;%do i = 1 %TO 3;&lt;/P&gt;&lt;P&gt;%let allCodes = %sysfunc(CATX(",", &amp;amp;Codes&amp;amp;i.&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&amp;amp;Codes4 ));&lt;/P&gt;&lt;P&gt;%put &amp;amp;allCodes;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;attempt1();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just trying to automate the macro&amp;nbsp;title() using DO loop but it gives errors...any ideas would be highly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tina&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 22:40:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automating-this-code-using-DO-LOOP/m-p/541640#M149572</guid>
      <dc:creator>rosegarden81</dc:creator>
      <dc:date>2019-03-08T22:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: Automating this code using DO LOOP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automating-this-code-using-DO-LOOP/m-p/541653#M149581</link>
      <description>&lt;P&gt;don't you need to array codes1 through codes3 before you us the do I = 1 to 3?&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 23:16:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automating-this-code-using-DO-LOOP/m-p/541653#M149581</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-03-08T23:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: Automating this code using DO LOOP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automating-this-code-using-DO-LOOP/m-p/541655#M149583</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; There is no need to use %SYSFUNC or the CATX function. Consider this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let string1 = I like;
%let string2 = Kermit;
%let string3 = the;
%let string4 = Frog;
%let bigstring = &amp;amp;string1 &amp;amp;string2 &amp;amp;string3 &amp;amp;string4;

%put &amp;amp;=string1 &amp;amp;=string2 &amp;amp;=string3 &amp;amp;=string4;
%put &amp;amp;=bigstring;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and if I wanted to make BIGSTRING2 with a different character between the values, I could do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%let bigstring2 = &amp;amp;string1&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;~&lt;/STRONG&gt;&lt;/FONT&gt;&amp;amp;string2&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;#&lt;/STRONG&gt;&lt;/FONT&gt;&amp;amp;string3&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;^&lt;/FONT&gt;&lt;/STRONG&gt;&amp;amp;string4;

%put &amp;amp;=bigstring2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;CATX and SYSFUNC are not needed in what you describe.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 23:17:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automating-this-code-using-DO-LOOP/m-p/541655#M149583</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2019-03-08T23:17:33Z</dc:date>
    </item>
    <item>
      <title>Re: Automating this code using DO LOOP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automating-this-code-using-DO-LOOP/m-p/541656#M149584</link>
      <description>&lt;P&gt;Hi Cynthia,&lt;/P&gt;&lt;P&gt;Thing is this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a couple of codes like office visit codes, well child visit codes.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So currently it is two sets of codes:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let Codes1 = "a" "b";&amp;nbsp; &amp;nbsp;/*&amp;nbsp;office visit codes */&lt;/P&gt;&lt;P&gt;%let Codes2 = "c" "d" "e";&amp;nbsp; &amp;nbsp;/*&amp;nbsp;well child visit codes */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let allCodes = &amp;amp;Codes1. &amp;amp;Codes2.;&amp;nbsp; &amp;nbsp;/* this macro var allCodes will contain all codes that were separately defined above */&lt;/P&gt;&lt;P&gt;%put &amp;amp;allCodes.;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*&amp;nbsp; "a" "b"&amp;nbsp;"c" "d" "e" */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Eventually, a user will add other codes like dental codes, back pain codes, custom codes like this:&lt;/P&gt;&lt;P&gt;%let Codes3 = "aa" "bb" "cc";&amp;nbsp; /* dental */&lt;/P&gt;&lt;P&gt;%let Codes4 =&amp;nbsp;"xx" "yy" "zz";&amp;nbsp; /* Back pain codes */&lt;/P&gt;&lt;P&gt;%let Codes5 = "aaa" "bbb" "ccc"&amp;nbsp; /* arthritis codes */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I wanted the &amp;amp;allCodes macro variable to now contain all of these additional codes as well without me having to update the code like in this below:&lt;/P&gt;&lt;P&gt;%let&amp;nbsp; allCodes = &amp;amp;Codes1. &amp;amp;Codes2. &amp;amp;Codes3. &amp;amp;Codes4. &amp;amp;Codes5.;&amp;nbsp; &amp;nbsp;/* Do not want to append codes like this to update &amp;amp;allCodes because there could be 50 of such code types a user can add*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is why I was trying to use the macro above..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to update the &amp;amp;allCodes for future proc freq etc purposes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 23:29:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automating-this-code-using-DO-LOOP/m-p/541656#M149584</guid>
      <dc:creator>rosegarden81</dc:creator>
      <dc:date>2019-03-08T23:29:05Z</dc:date>
    </item>
    <item>
      <title>Re: Automating this code using DO LOOP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automating-this-code-using-DO-LOOP/m-p/541657#M149585</link>
      <description>&lt;P&gt;When you run this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let string1 = I like;
%let string2 = Kermit;
%let string3 = the;
%let string4 = Frog;

%put &amp;amp;=string1 &amp;amp;=string2 &amp;amp;=string3 &amp;amp;=string4;


%macro attempt ;
%global allcodes allcodes2;
%let allCodes =;
%do i = 1 %TO 4;

%let allCodes = &amp;amp;allCodes &amp;amp;&amp;amp;string&amp;amp;i;

%if &amp;amp;i = 1 %then %let allcodes2 = (&amp;amp;&amp;amp;string&amp;amp;i;
%else %let allcodes2 = &amp;amp;allcodes2 &amp;amp;&amp;amp;string&amp;amp;i;

%end;
%let allcodes2 = &amp;amp;allcodes2)%str(;);


%put &amp;amp;=allCodes &amp;amp;=allcodes2;

%mend attempt;

%attempt&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then &amp;amp;allcodes should have all 4 strings and allcodes2 should have parens and a semi-colon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 23:29:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automating-this-code-using-DO-LOOP/m-p/541657#M149585</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2019-03-08T23:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: Automating this code using DO LOOP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automating-this-code-using-DO-LOOP/m-p/541658#M149586</link>
      <description>&lt;P&gt;Thank you so much for this, I highly appreciate it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 23:37:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automating-this-code-using-DO-LOOP/m-p/541658#M149586</guid>
      <dc:creator>rosegarden81</dc:creator>
      <dc:date>2019-03-08T23:37:41Z</dc:date>
    </item>
  </channel>
</rss>

