<?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 Build a merge statement from macro values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Build-a-merge-statement-from-macro-values/m-p/352841#M82306</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I keep getting SO CLOSE but i can't get the final string to build.&amp;nbsp; I'm trying to dynamically build a proc sql merge statement with table aliases of A and B.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this:&lt;/P&gt;&lt;P&gt;%let merge1=cat_order grp_order year;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And i want to turn it into this:&lt;/P&gt;&lt;P&gt;a.cat_order=b.cat_order and a.grp_order=b.grp_order and a.year=b.year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The ANDs can be constant, but the merge1 values will be different everytime (sometimes i might have 2 of them, sometimes 3, sometimes 1, etc), so i've been trying to build the statement by parsing the words with countw and scan and i can get it to build part way, but i can't get it to cycle and build completely.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't put all of the code here because it's gone through about 10 different versions, so i don't even have some of the stuff i've tested so far, and what's left makes no sense because i got all turned around.&amp;nbsp; Maybe i was THIS close and just missed one thing, but then i tore it all apart again.&amp;nbsp; I don't know.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know in theory it's should be:&lt;/P&gt;&lt;P&gt;count the words. (ie 3)&amp;nbsp; &amp;lt;-- got this part to work.&lt;/P&gt;&lt;P&gt;create new macro variables with the word "and", one for each count. (join1, join2, join3)&amp;nbsp; &amp;lt;-- got this part to work.&lt;/P&gt;&lt;P&gt;build a string for each cycle with the "a." aliases, etc onto them ( a.cat_order=b.cat_order and )&amp;nbsp; &amp;lt;-- got this part to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Append the multiple strings together as one string &amp;lt;-- this is where i'm stuck. I built a dataset that has 3 fields with the content i want:&lt;/P&gt;&lt;P&gt;string1=a.cat_order=b.cat_order and&lt;/P&gt;&lt;P&gt;string2=a.grp_order=b.grp_order and&lt;/P&gt;&lt;P&gt;string3=a.year=b.year&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But because the # can change, i can't get for the life of me get it to cycle through and retain the first part.&amp;nbsp; I can't get %let str=str, string&amp;amp;i to work.&amp;nbsp; I've tried %sysfunc(catx(,str), etc but i keep getting a %sysfuncf error??&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If anyone can help with the third part, that'd be great.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;M&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 24 Apr 2017 13:30:00 GMT</pubDate>
    <dc:creator>MeganE</dc:creator>
    <dc:date>2017-04-24T13:30:00Z</dc:date>
    <item>
      <title>Build a merge statement from macro values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Build-a-merge-statement-from-macro-values/m-p/352841#M82306</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I keep getting SO CLOSE but i can't get the final string to build.&amp;nbsp; I'm trying to dynamically build a proc sql merge statement with table aliases of A and B.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this:&lt;/P&gt;&lt;P&gt;%let merge1=cat_order grp_order year;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And i want to turn it into this:&lt;/P&gt;&lt;P&gt;a.cat_order=b.cat_order and a.grp_order=b.grp_order and a.year=b.year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The ANDs can be constant, but the merge1 values will be different everytime (sometimes i might have 2 of them, sometimes 3, sometimes 1, etc), so i've been trying to build the statement by parsing the words with countw and scan and i can get it to build part way, but i can't get it to cycle and build completely.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't put all of the code here because it's gone through about 10 different versions, so i don't even have some of the stuff i've tested so far, and what's left makes no sense because i got all turned around.&amp;nbsp; Maybe i was THIS close and just missed one thing, but then i tore it all apart again.&amp;nbsp; I don't know.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know in theory it's should be:&lt;/P&gt;&lt;P&gt;count the words. (ie 3)&amp;nbsp; &amp;lt;-- got this part to work.&lt;/P&gt;&lt;P&gt;create new macro variables with the word "and", one for each count. (join1, join2, join3)&amp;nbsp; &amp;lt;-- got this part to work.&lt;/P&gt;&lt;P&gt;build a string for each cycle with the "a." aliases, etc onto them ( a.cat_order=b.cat_order and )&amp;nbsp; &amp;lt;-- got this part to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Append the multiple strings together as one string &amp;lt;-- this is where i'm stuck. I built a dataset that has 3 fields with the content i want:&lt;/P&gt;&lt;P&gt;string1=a.cat_order=b.cat_order and&lt;/P&gt;&lt;P&gt;string2=a.grp_order=b.grp_order and&lt;/P&gt;&lt;P&gt;string3=a.year=b.year&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But because the # can change, i can't get for the life of me get it to cycle through and retain the first part.&amp;nbsp; I can't get %let str=str, string&amp;amp;i to work.&amp;nbsp; I've tried %sysfunc(catx(,str), etc but i keep getting a %sysfuncf error??&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If anyone can help with the third part, that'd be great.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;M&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2017 13:30:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Build-a-merge-statement-from-macro-values/m-p/352841#M82306</guid>
      <dc:creator>MeganE</dc:creator>
      <dc:date>2017-04-24T13:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: Build a merge statement from macro values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Build-a-merge-statement-from-macro-values/m-p/352846#M82308</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data control;
input varname :$20.;
cards;
cat_order
grp_order
year
;
run;

data _null_;
set control end=done;
length wherestring $1000 ws $100;
retain wherestring;
ws = 'a.' !! trim(varname) !! '=b.' !! trim(varname);
wherestring = catx(' and ',trim(wherestring),ws);
if done then call symputx('wherestring',wherestring);
run;

%put &amp;amp;wherestring;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Don't keep a value list in a macro variable; put it in a dataset instead, and use the power of the data step language to process the values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See Maxim 11.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2017 13:42:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Build-a-merge-statement-from-macro-values/m-p/352846#M82308</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-04-24T13:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: Build a merge statement from macro values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Build-a-merge-statement-from-macro-values/m-p/352848#M82309</link>
      <description>&lt;P&gt;You do not want to use the CAT...() series of functions with %SYSFUNC(). &amp;nbsp;It is not needed and the fact data SYSFUNC() will need to make a guess as to whether the value is a number or a character string can cause confusion and worse.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are writing the code inside of a macro then just use a %DO loop.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let merge1=cat_order grp_order year;
%let want=;
%let separator=;
%do i=1 %to %sysfunc(countw(&amp;amp;merge1));
   %let word = %scan(&amp;amp;merge1,&amp;amp;i);
   %let want=&amp;amp;want &amp;amp;separator a.&amp;amp;word=b.&amp;amp;word ;
   %let separator=and;
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If not then do the same logic in a data step and use CALL SYMPUTX() to write the result bak into a macro variable. &amp;nbsp;In a data step you can use the CAT...() functions nicely for this problem.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  merge1="&amp;amp;merge1";
  length word $32 want $1000 ;
  do i=1 to countw(merge1);
    word=scan(merge1,i);
    want=catx(' and ',want,cats('A.',word,'=B.',word));
  end;
  call symputx('want',want);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Apr 2017 14:00:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Build-a-merge-statement-from-macro-values/m-p/352848#M82309</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-04-24T14:00:36Z</dc:date>
    </item>
    <item>
      <title>Re: Build a merge statement from macro values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Build-a-merge-statement-from-macro-values/m-p/352851#M82311</link>
      <description>&lt;P&gt;The list of variables to merge on comes from a macro variable.&amp;nbsp; But the first thing i did was put it in to a dataset.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2017 13:48:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Build-a-merge-statement-from-macro-values/m-p/352851#M82311</guid>
      <dc:creator>MeganE</dc:creator>
      <dc:date>2017-04-24T13:48:30Z</dc:date>
    </item>
    <item>
      <title>Re: Build a merge statement from macro values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Build-a-merge-statement-from-macro-values/m-p/352853#M82312</link>
      <description>&lt;P&gt;Start by posting some test data in the form of a datastep, and what the output should look like. &amp;nbsp;Why are you trying to create a dynamic join, seems a bit peculier to me. &amp;nbsp;You may find simpler methods to do such a thing. &amp;nbsp;For example, I have three datasets:&lt;/P&gt;
&lt;P&gt;DS=Abc&lt;/P&gt;
&lt;P&gt;ID &amp;nbsp;PARAM &amp;nbsp; RESULT&lt;/P&gt;
&lt;P&gt;DS=Def&lt;/P&gt;
&lt;P&gt;ID &amp;nbsp;PARAM &amp;nbsp; RESULT&lt;/P&gt;
&lt;P&gt;DS=EFG&lt;/P&gt;
&lt;P&gt;ID PARAM &amp;nbsp; &amp;nbsp;OUT&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now I can set these three together, assign a group per filename like below, then use that final dataset to transpose up. &amp;nbsp;By doing it this way I don't need to know what sets to merge together:&lt;/P&gt;
&lt;PRE&gt;data inter;
  set abc def efg (rename=(out=results)) indsname=nm;
  cat=nm;
run;

proc sort data=inter;
  by id param cat;
run;

proc transpose data=inter out=want;
  by id param;
  var result;
  id cat;
  idlabel cat;
run;&lt;/PRE&gt;
&lt;P&gt;This would give me:&lt;/P&gt;
&lt;P&gt;ID PARAM &amp;nbsp;ABC &amp;nbsp;DEF &amp;nbsp;EFG&lt;/P&gt;
&lt;P&gt;dataset without mergin all the elements.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2017 13:49:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Build-a-merge-statement-from-macro-values/m-p/352853#M82312</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-04-24T13:49:42Z</dc:date>
    </item>
    <item>
      <title>Re: Build a merge statement from macro values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Build-a-merge-statement-from-macro-values/m-p/352861#M82315</link>
      <description>&lt;P&gt;If I correctly understand what you are trying to do, here is one way you could do it using a SAS macro:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%macro doit(out=,file1=,file2=,criteria=);
  proc sql noprint;
    create table &amp;amp;out. as
      select *
        from &amp;amp;file1. a join &amp;amp;file2. b
          on
            %let i=1;
            %do %while (%scan(&amp;amp;criteria.,&amp;amp;i.,' ') ne );
              %if &amp;amp;i. gt 1 %then and ; 
               a.%scan(&amp;amp;criteria.,&amp;amp;i.,' ')=b.%scan(&amp;amp;criteria.,&amp;amp;i.,' ')
              %let i=&amp;amp;i.+1;
            %end;
    ;
  quit;
%mend doit;

data test1;
  input x y z;
  cards;
3 1 3
2 2 2
1 3 1
;

data test2;
  input x y a;
  cards;
3 1 6
2 2 5
1 3 4
;

%doit(out=want,file1=test1,file2=test2,criteria=x y)
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2017 14:05:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Build-a-merge-statement-from-macro-values/m-p/352861#M82315</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-04-24T14:05:22Z</dc:date>
    </item>
    <item>
      <title>Re: Build a merge statement from macro values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Build-a-merge-statement-from-macro-values/m-p/352862#M82316</link>
      <description>&lt;P&gt;Are you trying to build SQL join?&lt;/P&gt;
&lt;P&gt;Why not just use a normal data step merge? Then you can use the value as is.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  merge table1 table2
  by &amp;amp;merge1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Apr 2017 14:08:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Build-a-merge-statement-from-macro-values/m-p/352862#M82316</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-04-24T14:08:22Z</dc:date>
    </item>
    <item>
      <title>Re: Build a merge statement from macro values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Build-a-merge-statement-from-macro-values/m-p/352866#M82317</link>
      <description>&lt;P&gt;I tried the _null_ statement way and it was perfect!&amp;nbsp; In fact, it got rid of a bunch of other crap i did to try and achieve the same thing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2017 14:18:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Build-a-merge-statement-from-macro-values/m-p/352866#M82317</guid>
      <dc:creator>MeganE</dc:creator>
      <dc:date>2017-04-24T14:18:03Z</dc:date>
    </item>
    <item>
      <title>Re: Build a merge statement from macro values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Build-a-merge-statement-from-macro-values/m-p/352869#M82318</link>
      <description>&lt;P&gt;Habit.&amp;nbsp; I haven't merged two datasets through sort, sort, merge in years.&amp;nbsp; I always do it through proc sql and i already had it, and additional proc sql code to do other stuff written.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2017 14:24:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Build-a-merge-statement-from-macro-values/m-p/352869#M82318</guid>
      <dc:creator>MeganE</dc:creator>
      <dc:date>2017-04-24T14:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: Build a merge statement from macro values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Build-a-merge-statement-from-macro-values/m-p/352879#M82322</link>
      <description>&lt;P&gt;You can also take advantage of the NATURAL join. &amp;nbsp;You can use dataset options if you have some variable name conflicts.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table want as
  select * 
  from tableA (keep=&amp;amp;merge1 var1 var2)
  natural join
       tableB (keep=&amp;amp;merge1 var1 var3 rename=(var1=b_var1))
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Apr 2017 14:38:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Build-a-merge-statement-from-macro-values/m-p/352879#M82322</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-04-24T14:38:03Z</dc:date>
    </item>
    <item>
      <title>Re: Build a merge statement from macro values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Build-a-merge-statement-from-macro-values/m-p/352888#M82326</link>
      <description>&lt;P&gt;Found a&amp;nbsp;convenient solution, still for the sake of diversity...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My own approach (which is a modified version from my personal macro functions library).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;%macro join(ALIAS1,ALIAS2,VARLIST,VARNUM);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;%let varname=%scan(&amp;amp;VARLIST,&amp;amp;VARNUM,%str( ));&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;%if %str(&amp;amp;varname) ne %str() %then &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;amp;ALIAS1..&amp;amp;varname = &amp;amp;ALIAS2..&amp;amp;varname and %join(&amp;amp;ALIAS1,&amp;amp;ALIAS2,&amp;amp;VARLIST,%eval(&amp;amp;VARNUM+1));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;%else 1&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;%mend join;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Used like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;options mprint;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;proc sql noprint;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;create table mydata&amp;nbsp;as&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;select ...&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;on&amp;nbsp;%join(a,b,cat_order grp_order year,1);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;quit;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Will recursively build the join clause appending "and 1" at the end (doesn't affect the AND logic)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;MPRINT(JOIN): a.cat_order = b.cat_order and&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;MPRINT(JOIN): a.grp_order = b.grp_order and&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;MPRINT(JOIN): a.year = b.year and&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;MPRINT(JOIN): 1&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;ALIAS1=left alias,ALIAS2=right alias,VARLIST=columns list,VARNUM=first column to start&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Daniel Santos&amp;nbsp;@ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2017 14:45:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Build-a-merge-statement-from-macro-values/m-p/352888#M82326</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2017-04-24T14:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: Build a merge statement from macro values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Build-a-merge-statement-from-macro-values/m-p/352893#M82328</link>
      <description>&lt;P&gt;Cool method. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that I have found that if using other SQL dialects (like Teradata) you need to use expressions like 1=1 and 1=0 instead of 1 and 0 to represent always true or always false conditions.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2017 14:55:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Build-a-merge-statement-from-macro-values/m-p/352893#M82328</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-04-24T14:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: Build a merge statement from macro values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Build-a-merge-statement-from-macro-values/m-p/353578#M82548</link>
      <description>&lt;P&gt;Thank you Tom, and you are right. It should be modified as needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Actually the original macro has more parameters being one the logical final statement (&amp;amp;LOGIC), which could be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;AND 1&lt;/P&gt;
&lt;P&gt;OR 0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or whatever is required to not affect the whole statement logic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The operator between pairs is obtained from this also (%scan(&amp;amp;LOGIC,1))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Daniel Santos&amp;nbsp;@ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2017 07:47:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Build-a-merge-statement-from-macro-values/m-p/353578#M82548</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2017-04-26T07:47:47Z</dc:date>
    </item>
  </channel>
</rss>

