<?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 function to append a string in another macro varible in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-function-to-append-a-string-in-another-macro-varible/m-p/743354#M232721</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;something like below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%quote(t1.(cats(t1.&amp;amp;Meta_Columns_map.)))=%quote(t2.(cats(t2.&amp;amp;Meta_Columns_map.)))&lt;/PRE&gt;</description>
    <pubDate>Mon, 24 May 2021 11:53:42 GMT</pubDate>
    <dc:creator>David_Billa</dc:creator>
    <dc:date>2021-05-24T11:53:42Z</dc:date>
    <item>
      <title>Macro function to append a string in another macro varible</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-function-to-append-a-string-in-another-macro-varible/m-p/743335#M232711</link>
      <description>&lt;P&gt;I've the code as follows. In this code, t1. and t2. string is not appending to the value of macro variable Meta_Columns_map as I except. I believe we've to add some macro function before cats so that join condition will correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let Meta_Columns_map=Date,Purpose,Type,Name;

Proc sql;
    Create table Trans_Table as 
        Select t1.*,t2.ID as ID
            from Input t1 left join Temp1 t2 on (cats(t1.&amp;amp;Meta_Columns_map.)=cats(t2.&amp;amp;Meta_Columns_map.))
    ;
Quit;&lt;/PRE&gt;
&lt;P&gt;Error which I got is,&lt;/P&gt;
&lt;PRE&gt;MPRINT(ITBB_LOADER):   Proc sql;
MPRINT(ITBB_LOADER):   Create table Trans_Table as Select t1.*,t2.ID as ID from work.Extract1 t1 left join Temp1 t2 on 
(cats(t1.Date,Purpose,Type,Name)=cats(t2.Date,Purpose,Type,Name)) ;
ERROR: Ambiguous reference, column Purpose is in more than one table.
ERROR: Ambiguous reference, column Type is in more than one table.
ERROR: Ambiguous reference, column Name is in more than one table.&lt;/PRE&gt;
&lt;P&gt;Excepted join condition is &lt;EM&gt;(cats(t1.Date,t1.Purpose,t1.Type,Name)=cats(t2.Date,t2.Purpose,t2.Type,Name)) ;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In real life I do have many fields to in join condition and it may change often and that's why I was asked to use only this approach and not any other method. Any help?&lt;/P&gt;</description>
      <pubDate>Mon, 24 May 2021 10:47:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-function-to-append-a-string-in-another-macro-varible/m-p/743335#M232711</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-05-24T10:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: Macro function to append a string in another macro varible</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-function-to-append-a-string-in-another-macro-varible/m-p/743339#M232714</link>
      <description>&lt;P&gt;Make it unambiguous for the table aliases:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Meta_Columns_map_t1=t1.Date,t1.Purpose,t1.Type,t1.Name;
%let Meta_Columns_map_t2=t2.Date,t2.Purpose,t2.Type,t2.Name;

proc sql;
create table Trans_Table as 
  select t1.*,t2.ID as ID
  from Input t1 left join Temp1 t2
  on (cats(&amp;amp;Meta_Columns_map_t1.)=cats(&amp;amp;Meta_Columns_map_t2.))
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that using CATS like this might create false matches&lt;/P&gt;
&lt;P&gt;cats("12","1") = cats("1","21") !!&lt;/P&gt;</description>
      <pubDate>Mon, 24 May 2021 11:03:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-function-to-append-a-string-in-another-macro-varible/m-p/743339#M232714</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-05-24T11:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: Macro function to append a string in another macro varible</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-function-to-append-a-string-in-another-macro-varible/m-p/743341#M232715</link>
      <description>&lt;P&gt;With a change to your map variable and some macro coding, you can try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Meta_Columns_map=Date Purpose Type Name;

%macro do_sql;
proc sql;
create table Trans_Table as 
  select t1.*,t2.ID as ID
  from Input t1 left join Temp1 t2 on
%do i = 1 to %sysfunc(countw(&amp;amp;Meta_Columns_map.,));
  %if &amp;amp;i. &amp;gt; 1 %then %do;
  and 
  %end;
  t1.%scan(&amp;amp;Meta_Columns_map.,&amp;amp;i.) = t2.%scan(&amp;amp;Meta_Columns_map.,&amp;amp;i.) 
%end;
;
quit;
%mend do_sql;
%do_sql&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(Untested)&lt;/P&gt;</description>
      <pubDate>Mon, 24 May 2021 11:08:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-function-to-append-a-string-in-another-macro-varible/m-p/743341#M232715</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-05-24T11:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: Macro function to append a string in another macro varible</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-function-to-append-a-string-in-another-macro-varible/m-p/743348#M232719</link>
      <description>&lt;P&gt;Thanks. Can I accomplish it without Looping? Once upon a time I achived it using quoting function in one single line but I'm unable to recall it fully which I done in the past.&lt;/P&gt;</description>
      <pubDate>Mon, 24 May 2021 11:40:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-function-to-append-a-string-in-another-macro-varible/m-p/743348#M232719</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-05-24T11:40:27Z</dc:date>
    </item>
    <item>
      <title>Re: Macro function to append a string in another macro varible</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-function-to-append-a-string-in-another-macro-varible/m-p/743354#M232721</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;something like below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%quote(t1.(cats(t1.&amp;amp;Meta_Columns_map.)))=%quote(t2.(cats(t2.&amp;amp;Meta_Columns_map.)))&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 May 2021 11:53:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-function-to-append-a-string-in-another-macro-varible/m-p/743354#M232721</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-05-24T11:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: Macro function to append a string in another macro varible</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-function-to-append-a-string-in-another-macro-varible/m-p/743396#M232739</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks. Can I accomplish it without Looping? Once upon a time I achived it using quoting function in one single line but I'm unable to recall it fully which I done in the past.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Use TRANWRD().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Meta_Columns_map=Date,Purpose,Type,Name;
%let t1=t1.%sysfunc(tranwrd(%superq(Meta_Columns_map),%str(,),%str(,t1.)));
%let t2=t2.%sysfunc(tranwrd(%superq(Meta_Columns_map),%str(,),%str(,t2.)));
...
on (catx('|',&amp;amp;t1) = catx('|',&amp;amp;t2))
...&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 May 2021 16:58:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-function-to-append-a-string-in-another-macro-varible/m-p/743396#M232739</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-24T16:58:18Z</dc:date>
    </item>
  </channel>
</rss>

