<?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 How do I pass a macro variable as a macro parameter in All Things Community</title>
    <link>https://communities.sas.com/t5/All-Things-Community/How-do-I-pass-a-macro-variable-as-a-macro-parameter/m-p/578179#M3975</link>
    <description>&lt;P&gt;Hello community,&lt;/P&gt;
&lt;P&gt;I've tried several different ways in an attempt to pass the location of the excel file to this macro.&lt;/P&gt;
&lt;P&gt;But I keep getting nothing. My logs just showed the code I rant. So I started using option symbolgen and mlogic&lt;/P&gt;
&lt;P&gt;to see if that would produce something for me. It did. It at least gave me the value of &amp;amp;path.&lt;/P&gt;
&lt;P&gt;Also I did hard code this and it worked perfectly fine.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PLEASE HELP AND THANKS IN ADVANCE&lt;/P&gt;
&lt;P&gt;I'm using Base SAS 9.4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;options symbolgen mlogic;&lt;BR /&gt;%Let path = C:\mysdtm\SDTM_METADATA.xlsx;&lt;BR /&gt;%put NOTE: &amp;amp;path;&lt;BR /&gt;%macro make_blank_dataset(metadatafile=,dataset=);&lt;BR /&gt;proc import &lt;BR /&gt;datafile="&amp;amp;metadatafile"&lt;BR /&gt;out=_temp&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options symbolgen mlogic;
%Let path = C:\mysdtm\SDTM_METADATA.xlsx;
%put NOTE: &amp;amp;path;
%macro make_empty_dataset(metadatafile=,dataset=);
    proc import 
        datafile="&amp;amp;metadatafile"
        out=_temp 
        dbms=excelcs
        replace;
        sheet="VARIABLE_METADATA";
    run;
%mend make_empty_dataset;
%macro make_empty_dataset(path, AE);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;dbms=excelcs&lt;BR /&gt;replace;&lt;BR /&gt;sheet="VARIABLE_METADATA";&lt;BR /&gt;run;&lt;BR /&gt;%mend make_empty_dataset;&lt;BR /&gt;%macro make_blank_dataset(path, AE);&lt;/P&gt;</description>
    <pubDate>Wed, 31 Jul 2019 18:47:27 GMT</pubDate>
    <dc:creator>cj9000</dc:creator>
    <dc:date>2019-07-31T18:47:27Z</dc:date>
    <item>
      <title>How do I pass a macro variable as a macro parameter</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-do-I-pass-a-macro-variable-as-a-macro-parameter/m-p/578179#M3975</link>
      <description>&lt;P&gt;Hello community,&lt;/P&gt;
&lt;P&gt;I've tried several different ways in an attempt to pass the location of the excel file to this macro.&lt;/P&gt;
&lt;P&gt;But I keep getting nothing. My logs just showed the code I rant. So I started using option symbolgen and mlogic&lt;/P&gt;
&lt;P&gt;to see if that would produce something for me. It did. It at least gave me the value of &amp;amp;path.&lt;/P&gt;
&lt;P&gt;Also I did hard code this and it worked perfectly fine.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PLEASE HELP AND THANKS IN ADVANCE&lt;/P&gt;
&lt;P&gt;I'm using Base SAS 9.4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;options symbolgen mlogic;&lt;BR /&gt;%Let path = C:\mysdtm\SDTM_METADATA.xlsx;&lt;BR /&gt;%put NOTE: &amp;amp;path;&lt;BR /&gt;%macro make_blank_dataset(metadatafile=,dataset=);&lt;BR /&gt;proc import &lt;BR /&gt;datafile="&amp;amp;metadatafile"&lt;BR /&gt;out=_temp&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options symbolgen mlogic;
%Let path = C:\mysdtm\SDTM_METADATA.xlsx;
%put NOTE: &amp;amp;path;
%macro make_empty_dataset(metadatafile=,dataset=);
    proc import 
        datafile="&amp;amp;metadatafile"
        out=_temp 
        dbms=excelcs
        replace;
        sheet="VARIABLE_METADATA";
    run;
%mend make_empty_dataset;
%macro make_empty_dataset(path, AE);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;dbms=excelcs&lt;BR /&gt;replace;&lt;BR /&gt;sheet="VARIABLE_METADATA";&lt;BR /&gt;run;&lt;BR /&gt;%mend make_empty_dataset;&lt;BR /&gt;%macro make_blank_dataset(path, AE);&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 18:47:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-do-I-pass-a-macro-variable-as-a-macro-parameter/m-p/578179#M3975</guid>
      <dc:creator>cj9000</dc:creator>
      <dc:date>2019-07-31T18:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: How do I pass a macro variable as a macro parameter</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-do-I-pass-a-macro-variable-as-a-macro-parameter/m-p/578181#M3976</link>
      <description>&lt;P&gt;Instead of&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro make_empty_dataset(path, AE);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you need&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%make_empty_dataset(metadatafile=&amp;amp;path, dataset=AE)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Although nowhere have you specified what AE is, and maccro variable &amp;amp;DATASET is not used in the macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 18:56:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-do-I-pass-a-macro-variable-as-a-macro-parameter/m-p/578181#M3976</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-07-31T18:56:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do I pass a macro variable as a macro parameter</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-do-I-pass-a-macro-variable-as-a-macro-parameter/m-p/578184#M3977</link>
      <description>&lt;P&gt;You use the %MACRO statement when DEFINING a macro.&amp;nbsp; Then CALLING the macro you just use its name.&lt;/P&gt;
&lt;P&gt;Your log is not showing anything because it is still waiting for the %MEND statement to mark the end of the new definition for the macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To reference the VALUE or a macro variable you use &amp;amp; before the name of the macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you define a macro parameter using = then it is considered a NAMED parameter instead of POSITIONAL parameter. You cannot pass value to named parameters without including the name in the macro call. (although you can pass values for positional parameters by including the name).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So your call should look like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%make_empty_dataset(metadatafile=&amp;amp;path, dataset=AE)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that your macro never uses the value of the dataset parameter anywhere.&amp;nbsp; Perhaps you want to change this section of the macro definition?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  out=&amp;amp;dataset&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 19:13:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-do-I-pass-a-macro-variable-as-a-macro-parameter/m-p/578184#M3977</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-31T19:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: How do I pass a macro variable as a macro parameter</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-do-I-pass-a-macro-variable-as-a-macro-parameter/m-p/578186#M3978</link>
      <description>Thank you, thank you. It's the small things we overlook I guess, like dropping the word %macro and also adding an amper to path.&lt;BR /&gt;So this is just a snippet of a larger program. I just cut it off at the beginning in an attempt to get the connection working. AE is the adverse event dataset name. Eventually I will have this iterate all of the domain metadata. Thanks again.</description>
      <pubDate>Wed, 31 Jul 2019 19:15:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-do-I-pass-a-macro-variable-as-a-macro-parameter/m-p/578186#M3978</guid>
      <dc:creator>cj9000</dc:creator>
      <dc:date>2019-07-31T19:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I pass a macro variable as a macro parameter</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-do-I-pass-a-macro-variable-as-a-macro-parameter/m-p/578191#M3979</link>
      <description>Thank you Tom for explaining this in industry terminology. Question: So when using a positional parameter I would just drop the = sign in both the Macro statement and the Macro call?</description>
      <pubDate>Wed, 31 Jul 2019 19:26:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-do-I-pass-a-macro-variable-as-a-macro-parameter/m-p/578191#M3979</guid>
      <dc:creator>cj9000</dc:creator>
      <dc:date>2019-07-31T19:26:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do I pass a macro variable as a macro parameter</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-do-I-pass-a-macro-variable-as-a-macro-parameter/m-p/578197#M3980</link>
      <description>&lt;P&gt;Pretty much.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you define the macro if the parameter name is NOT followed by the = then you CAN call it by position.&amp;nbsp; When the parameter IS followed by the = then use MUST call it by name.&amp;nbsp;You must define any positional parameters before any named parameters.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When calling the macro you can pass the positional parameter values in without their names, just by the position in the call.&amp;nbsp; But you can also call them by their name if you want.&amp;nbsp; Note that when calling the macro any values passed by position must appear before any named values. Also when passing values by name the order that the parameters appear in the call does not need to match the order that the parameters were defined in the %MACRO statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 19:40:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-do-I-pass-a-macro-variable-as-a-macro-parameter/m-p/578197#M3980</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-31T19:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do I pass a macro variable as a macro parameter</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-do-I-pass-a-macro-variable-as-a-macro-parameter/m-p/578208#M3981</link>
      <description>Good stuff to know, thank you.&lt;BR /&gt;</description>
      <pubDate>Wed, 31 Jul 2019 20:00:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-do-I-pass-a-macro-variable-as-a-macro-parameter/m-p/578208#M3981</guid>
      <dc:creator>cj9000</dc:creator>
      <dc:date>2019-07-31T20:00:43Z</dc:date>
    </item>
  </channel>
</rss>

