<?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 - parameter of parameters? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-parameter-of-parameters/m-p/583015#M165916</link>
    <description>&lt;P&gt;Take a look at my changes. I have not tested it, but eyeballing it I think it should work.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let yr=2017;
%let yr2=2018;

%let DB1var=v1 v2 v3 v4;
%let DB2var=x5 x7 x14 x5;
%let DB1name=mylib1.dt_A&amp;amp;yr;  *mylib1.dt_A2017; /* Changed &amp;amp;fy to &amp;amp;yr */
%let DB2name=mylib2.dt_B&amp;amp;yr2;  *mylib2.dt_B2018; /* Changed &amp;amp;fy2 to &amp;amp;yr2 */

%macro get (db=, var=, dbname=);
proc sql; create table &amp;amp;db as select a.*, b.*
		from have (where= (&amp;amp;db=1)  ) as a 
		left join &amp;amp;dbname (keep=ID &amp;amp;var) as b /* Added ID to the keep statement, Removed &amp;amp; from &amp;amp;&amp;amp;dbname, changed &amp;amp;dbvav to &amp;amp;var */
		on a.ID=b.ID; quit; /* Changed b/OD to b.ID (I think that was a typo) */
%mend;
%get (db=DB1,  var=&amp;amp;DB1var, dbname= &amp;amp;DB1name) ; /* Removed extra close parenthesis, Added &amp;amp; to value in var and dbName */
%get (db=DB2,  var=&amp;amp;DB2var, dbname= &amp;amp;DB2name) ;&amp;nbsp;/* Removed extra close parenthesis, Added &amp;amp; to value in var and dbName, changed DB1name to DB2name */&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 21 Aug 2019 22:00:46 GMT</pubDate>
    <dc:creator>Urban_Science</dc:creator>
    <dc:date>2019-08-21T22:00:46Z</dc:date>
    <item>
      <title>Macro - parameter of parameters?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-parameter-of-parameters/m-p/583014#M165915</link>
      <description>&lt;P&gt;Hi I've a simple SQL work to read in several data sets and keep selective variables from the data, so I used macro. Since the variable list is long and etc. I thought I'd spell out using %let before the macro. When calling in the macro %get, it apparently doesn't recognize these parameters. What do I do, make them system variables? Hope it makes sense. Thanks in advance.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let yr=2017;
%let yr2=2018;

%let DB1var=v1 v2 v3 v4;
%let DB2var=x5 x7 x14 x5;
%let DB1name=mylib1.dt_A&amp;amp;fy;  *mylib1.dt_A2017;
%let DB2name=mylib2.dt_B&amp;amp;fy2;  *mylib2.dt_B2018;

%macro get (db=, var=, dbname=);
proc sql; create table &amp;amp;db as select a.*, b.*
		from have (where= (&amp;amp;db=1)  ) as a 
		left join &amp;amp;&amp;amp;dbname (keep=&amp;amp;dbvav) as b 
		on a.ID=b/OD; quit;
%mend;
%get (db=DB1,  var=DB1var, dbname= DB1name) ) ;
%get (db=DB2,  var=DB2var, dbname= DB1name) ) ;
&lt;BR /&gt;/*It is how it should be executed if I'm doing it right*/
proc sql; create table DB1 as select b.*  
	from have (where= (DB1=1)  ) as a 
	left join DT_A2017 (keep=v1 v2 v3 v4) as b on a.ID=b.ID; 
quit;
/*What it actually turns out*/
proc sql; create table DB1 as select b.*  
	from have (where= (DB1=1)  ) as a 
	left join DB1name (keep=DB1var) as b on a.ID=b.ID; 
quit;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 21:19:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-parameter-of-parameters/m-p/583014#M165915</guid>
      <dc:creator>Solph</dc:creator>
      <dc:date>2019-08-21T21:19:24Z</dc:date>
    </item>
    <item>
      <title>Re: Macro - parameter of parameters?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-parameter-of-parameters/m-p/583015#M165916</link>
      <description>&lt;P&gt;Take a look at my changes. I have not tested it, but eyeballing it I think it should work.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let yr=2017;
%let yr2=2018;

%let DB1var=v1 v2 v3 v4;
%let DB2var=x5 x7 x14 x5;
%let DB1name=mylib1.dt_A&amp;amp;yr;  *mylib1.dt_A2017; /* Changed &amp;amp;fy to &amp;amp;yr */
%let DB2name=mylib2.dt_B&amp;amp;yr2;  *mylib2.dt_B2018; /* Changed &amp;amp;fy2 to &amp;amp;yr2 */

%macro get (db=, var=, dbname=);
proc sql; create table &amp;amp;db as select a.*, b.*
		from have (where= (&amp;amp;db=1)  ) as a 
		left join &amp;amp;dbname (keep=ID &amp;amp;var) as b /* Added ID to the keep statement, Removed &amp;amp; from &amp;amp;&amp;amp;dbname, changed &amp;amp;dbvav to &amp;amp;var */
		on a.ID=b.ID; quit; /* Changed b/OD to b.ID (I think that was a typo) */
%mend;
%get (db=DB1,  var=&amp;amp;DB1var, dbname= &amp;amp;DB1name) ; /* Removed extra close parenthesis, Added &amp;amp; to value in var and dbName */
%get (db=DB2,  var=&amp;amp;DB2var, dbname= &amp;amp;DB2name) ;&amp;nbsp;/* Removed extra close parenthesis, Added &amp;amp; to value in var and dbName, changed DB1name to DB2name */&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Aug 2019 22:00:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-parameter-of-parameters/m-p/583015#M165916</guid>
      <dc:creator>Urban_Science</dc:creator>
      <dc:date>2019-08-21T22:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: Macro - parameter of parameters?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-parameter-of-parameters/m-p/583016#M165917</link>
      <description>Not an answer to your question, but you can use MPRINT to see exactly what SAS is seeing. &lt;BR /&gt;&lt;BR /&gt;Use the following options to help you debug macros. You can choose which ones you need;&lt;BR /&gt;MLOGIC is usually a last resort for me. &lt;BR /&gt;&lt;BR /&gt;options mprint symbolgen mlogic;</description>
      <pubDate>Wed, 21 Aug 2019 21:30:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-parameter-of-parameters/m-p/583016#M165917</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-08-21T21:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: Macro - parameter of parameters?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-parameter-of-parameters/m-p/583019#M165920</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/89585"&gt;@Urban_Science&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Take a look at my changes. I have not tested it, but eyeballing it I think it should work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let &lt;FONT size="4"&gt;&lt;STRONG&gt;&lt;FONT color="#3366ff"&gt;yr&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;=2017;
%let &lt;FONT size="4"&gt;&lt;STRONG&gt;&lt;FONT color="#3366ff"&gt;yr2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;=2018;

%let DB1var=v1 v2 v3 v4;
%let DB2var=x5 x7 x14 x5;
%let DB1name=mylib1.dt_A&amp;amp;&lt;FONT size="4"&gt;&lt;STRONG&gt;&lt;FONT color="#ff0000"&gt;fy&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;;  *mylib1.dt_A2017;
%let DB2name=mylib2.dt_B&amp;amp;&lt;FONT size="4"&gt;&lt;STRONG&gt;&lt;FONT color="#ff0000"&gt;fy2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;;  *mylib2.dt_B2018;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think that you may want start by addressing the year component of these variables. I don't see a definition for the macro variables FY or FY2.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 21:41:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-parameter-of-parameters/m-p/583019#M165920</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-08-21T21:41:15Z</dc:date>
    </item>
    <item>
      <title>Re: Macro - parameter of parameters?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-parameter-of-parameters/m-p/583020#M165921</link>
      <description>Good catch, I've updated my response. Thanks!</description>
      <pubDate>Wed, 21 Aug 2019 21:44:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-parameter-of-parameters/m-p/583020#M165921</guid>
      <dc:creator>Urban_Science</dc:creator>
      <dc:date>2019-08-21T21:44:00Z</dc:date>
    </item>
    <item>
      <title>Re: Macro - parameter of parameters?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-parameter-of-parameters/m-p/583021#M165922</link>
      <description>&lt;P&gt;Thanks. I worked. I thought I tried it and it didn't work. But apparently it works well. Again thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 21:55:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-parameter-of-parameters/m-p/583021#M165922</guid>
      <dc:creator>Solph</dc:creator>
      <dc:date>2019-08-21T21:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: Macro - parameter of parameters?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-parameter-of-parameters/m-p/583022#M165923</link>
      <description>No problem! I made a couple of updates along the way. My latest update a few minutes ago was to include ID in the keep statement; otherwise, the column wouldn't exist for the join. &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt; noticed the typo in the let statements, which I missed because I was too focused on what was going on in the macro. Team effort! Glad it works!</description>
      <pubDate>Wed, 21 Aug 2019 21:58:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-parameter-of-parameters/m-p/583022#M165923</guid>
      <dc:creator>Urban_Science</dc:creator>
      <dc:date>2019-08-21T21:58:50Z</dc:date>
    </item>
  </channel>
</rss>

