<?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: Macro isn't working in the second column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-isn-t-working-in-the-second-column/m-p/673898#M202819</link>
    <description>&lt;P&gt;When you run&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%type(Post)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this creates a data set CONCATENATE where Post is cleaned up properly. Then you run&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%type(Mail)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and this creates a brand new data set CONCATENATE where Mail is cleaned up properly, overwriting the previous data set CONCATENATE where Post is cleaned up properly. The end result is a data set CONCATENATE where only Mail is cleaned up properly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to re-design your logic here. A method that is superior to using macros in this case is to use an ARRAY inside data set CONCATENTATE. ARRAYs can loop over variables and execute the same portion of code on each variable in the array.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data concatenate;
set addresses;
Mail = cats(Mail_addr1,Mail_addr2);
Post = cats(post_addr1,post_addr2);
array column(*) mail post; /* You can have more than two columns here */
do i=1 to dim(column);
column(i) = strip(tranwrd(column(i),'C/O ',''));
column(i) = strip(tranwrd(column(i),'The Manager ',''));
end;
if Mail = Post then same = 'yes'; else same='no';
drop Mail_addr: Post_addr: i;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 01 Aug 2020 19:08:28 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-08-01T19:08:28Z</dc:date>
    <item>
      <title>Macro isn't working in the second column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-isn-t-working-in-the-second-column/m-p/673896#M202817</link>
      <description>&lt;P&gt;I've created some code that concatenates the mailing address variables together and the postal address variables, and then compares the two to see if they are the same. Some need to be stripped of things like "the manager" or "C/O" in front of the addresses, so I created a macro that is supposed to go over both the concatenated fields and remove these, however, it is only working on the concatenated Mail. I tried&amp;nbsp;%type(Post Mail); which I'd seen on another example, but that doesn't work either. Any thoughts please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data addresses;&lt;BR /&gt;infile datalines dlm=',' dsd truncover;&lt;BR /&gt;input Mail_addr1 :$30. Mail_addr2 :$10. Post_addr1 :$30. Post_addr2 :$10.;&lt;BR /&gt;datalines;&lt;BR /&gt;10 Downing St,London,C/O 10 Downing St,London&lt;BR /&gt;C/O 1600 Pennsylvania Avenue,Washington,1600 Pennsylvania Avenue,Washington&lt;BR /&gt;The Manager 12 North St,Anytown,12 North St,Anytown&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;%macro type(type);&lt;BR /&gt;data concatenate;&lt;BR /&gt;set addresses;&lt;BR /&gt;Mail = cats(Mail_addr1,Mail_addr2);&lt;BR /&gt;Post = cats(post_addr1,post_addr2);&lt;BR /&gt;&lt;BR /&gt;&amp;amp;type = strip(tranwrd(&amp;amp;type,'C/O ',''));&lt;BR /&gt;&amp;amp;type = strip(tranwrd(&amp;amp;type,'The Manager ',''));&lt;BR /&gt;&lt;BR /&gt;if Mail = Post then same = 'yes'; else same='no';&lt;BR /&gt;drop Mail_addr: Post_addr:;&lt;BR /&gt;run;&lt;BR /&gt;%mend;&lt;BR /&gt;%type(Post);&lt;BR /&gt;%type(Mail);&lt;/P&gt;</description>
      <pubDate>Sat, 01 Aug 2020 11:29:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-isn-t-working-in-the-second-column/m-p/673896#M202817</guid>
      <dc:creator>Buzzy_Bee</dc:creator>
      <dc:date>2020-08-01T11:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: Macro isn't working in the second column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-isn-t-working-in-the-second-column/m-p/673898#M202819</link>
      <description>&lt;P&gt;When you run&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%type(Post)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this creates a data set CONCATENATE where Post is cleaned up properly. Then you run&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%type(Mail)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and this creates a brand new data set CONCATENATE where Mail is cleaned up properly, overwriting the previous data set CONCATENATE where Post is cleaned up properly. The end result is a data set CONCATENATE where only Mail is cleaned up properly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to re-design your logic here. A method that is superior to using macros in this case is to use an ARRAY inside data set CONCATENTATE. ARRAYs can loop over variables and execute the same portion of code on each variable in the array.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data concatenate;
set addresses;
Mail = cats(Mail_addr1,Mail_addr2);
Post = cats(post_addr1,post_addr2);
array column(*) mail post; /* You can have more than two columns here */
do i=1 to dim(column);
column(i) = strip(tranwrd(column(i),'C/O ',''));
column(i) = strip(tranwrd(column(i),'The Manager ',''));
end;
if Mail = Post then same = 'yes'; else same='no';
drop Mail_addr: Post_addr: i;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Aug 2020 19:08:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-isn-t-working-in-the-second-column/m-p/673898#M202819</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-08-01T19:08:28Z</dc:date>
    </item>
    <item>
      <title>Re: Macro isn't working in the second column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-isn-t-working-in-the-second-column/m-p/673946#M202844</link>
      <description>&lt;P&gt;Thanks PaigeMiller. That works perfectly and it's easier to read than using macros with fewer lines of code.&lt;/P&gt;</description>
      <pubDate>Sat, 01 Aug 2020 20:23:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-isn-t-working-in-the-second-column/m-p/673946#M202844</guid>
      <dc:creator>Buzzy_Bee</dc:creator>
      <dc:date>2020-08-01T20:23:43Z</dc:date>
    </item>
  </channel>
</rss>

