<?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: Macros in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macros/m-p/770501#M244462</link>
    <description>Thanks Paige and Shmuel.</description>
    <pubDate>Sun, 26 Sep 2021 14:33:07 GMT</pubDate>
    <dc:creator>asuman</dc:creator>
    <dc:date>2021-09-26T14:33:07Z</dc:date>
    <item>
      <title>Macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros/m-p/770406#M244414</link>
      <description>&lt;P&gt;data t1;&lt;BR /&gt;input year volume diff_pr prob forb;&lt;BR /&gt;cards;&lt;BR /&gt;2018 204010 2380 4898 5740&lt;BR /&gt;2019 208765 4678 7659 9862&lt;BR /&gt;2020 279868 7654 8762 8257&lt;BR /&gt;2021 215678 8721 9821 7627&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;data t2;&lt;BR /&gt;set t1;&lt;BR /&gt;match_rate_1 = (volume-diff_pr)/volume;&lt;BR /&gt;match_rate_2 = (volume-prob)/volume;&lt;BR /&gt;match_rate_3 = (volume-forb)/volume;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can we automate the way match_rate is calculated.&lt;/P&gt;</description>
      <pubDate>Sat, 25 Sep 2021 12:37:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros/m-p/770406#M244414</guid>
      <dc:creator>asuman</dc:creator>
      <dc:date>2021-09-25T12:37:47Z</dc:date>
    </item>
    <item>
      <title>Re: Macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros/m-p/770407#M244415</link>
      <description>&lt;P&gt;I see nothing to automate here; the code will calculate the whole dataset on its own.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: and if you want to make this dynamic, you need to tell us which parts have to change, and the rules for the change.&lt;/P&gt;</description>
      <pubDate>Sat, 25 Sep 2021 13:02:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros/m-p/770407#M244415</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-25T13:02:18Z</dc:date>
    </item>
    <item>
      <title>Re: Macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros/m-p/770409#M244417</link>
      <description>Hi Kurt,&lt;BR /&gt;My question is that if in table t1 we have 20 more columns then in table t2 we have to define match rate for those 20 columns also.And if we use different tables, then every time we have to make changes in match rate formula as per new columns.&lt;BR /&gt;so i am asking is there any way we can automate such a way like match rate will be calculated based on the columns in table t1.</description>
      <pubDate>Sat, 25 Sep 2021 13:10:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros/m-p/770409#M244417</guid>
      <dc:creator>asuman</dc:creator>
      <dc:date>2021-09-25T13:10:05Z</dc:date>
    </item>
    <item>
      <title>Re: Macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros/m-p/770411#M244418</link>
      <description>&lt;P&gt;If I understand you correctly, what you are looking for is not a macro but using array,&lt;/P&gt;
&lt;P&gt;as demostrated in next code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data t2;
  set t1;
       array mr {*} match_rate1-match_rate_3;
       array vx {*} diff_pr prob forb;
       do i=1 to dim(vx);
           mr(i) = (volume - vx(i)) / volume;
       end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 25 Sep 2021 13:45:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros/m-p/770411#M244418</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-09-25T13:45:46Z</dc:date>
    </item>
    <item>
      <title>Re: Macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros/m-p/770432#M244428</link>
      <description>&lt;P&gt;Certainly, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt; has a better solution than macros.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/148419"&gt;@asuman&lt;/a&gt;, I really wonder about the value of associating variable diff_pr to match_rate_1, prob to match_rate_2 and forb to match_rate_3, how does assigning a sequential number to an otherwise constant variable name help anything for anyone? You are creating unintelligible and meaningless names. It seems as if you are causing confusion and difficulty, rather than bringing some sort of understanding to the new variable names.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Instead of match_rate_1 through match_rate_3, how about diff_pr_rate, prob_rate and forb_rate?????? Now, users can EASILY understand which rate is which variable. That's a solution I (and others) can sink my teeth into, figuratively speaking of course. And still, you don't need a macro, but you do need a macro variable (or at least, that's how I would do it, maybe there is a way to do this without using a macro variable).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;   
    select name into :orignames separated by ' ' from dictionary.columns where libname='WORK' and memname='T1' and 
        name not in ('year','volume');
    select cats(name,'_rate') into :ratenames separated by ' '
        from dictionary.columns where libname='WORK' and memname='T1' and 
        name not in ('year','volume');
quit;

data t2;
  set t1;
       array vx {*} &amp;amp;orignames;
       array mr &amp;amp;ratenames;
       do i=1 to dim(vx);
           mr(i) = (volume - vx(i)) / volume; 
       end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Sep 2021 10:48:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros/m-p/770432#M244428</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-09-26T10:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: Macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros/m-p/770434#M244429</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;, you nicely expanded my solution.</description>
      <pubDate>Sat, 25 Sep 2021 19:58:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros/m-p/770434#M244429</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-09-25T19:58:00Z</dc:date>
    </item>
    <item>
      <title>Re: Macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros/m-p/770501#M244462</link>
      <description>Thanks Paige and Shmuel.</description>
      <pubDate>Sun, 26 Sep 2021 14:33:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros/m-p/770501#M244462</guid>
      <dc:creator>asuman</dc:creator>
      <dc:date>2021-09-26T14:33:07Z</dc:date>
    </item>
  </channel>
</rss>

