<?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: How to pass file names as macro prameters? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228346#M41245</link>
    <description>How does the macro variable &amp;amp;base will get resolve? Because it was declared in your example. &lt;BR /&gt;&lt;BR /&gt;Thanks again for your continued support.</description>
    <pubDate>Sun, 04 Oct 2015 09:37:27 GMT</pubDate>
    <dc:creator>Babloo</dc:creator>
    <dc:date>2015-10-04T09:37:27Z</dc:date>
    <item>
      <title>How to pass file names as macro prameters?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/227996#M41128</link>
      <description>&lt;P&gt;I've&amp;nbsp; a requirement to pass file names as argument to create a dataset. As of now, I've the code where I read file names from .txt file and then calling macro, but my managements wants me&amp;nbsp;to pass file names as argument by considering the future requirements.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My Existing code will be like,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data log.output_file ;
  infile "&amp;amp;path/output_file.txt" firstobs=2 truncover ;
  input fname $400. ;
run;

%macro log_analysis;

data log.log_analysis;
set log.output_file;
filename=fname;
length fname $400;
infile dummy dsd truncover FILEVAR = fname END = end_of_file LRECL=32000;
DO WHILE (not end_of_file);
input var : $ 3000.;
..........
..........
%mend log_analysis;

data _null_;
  set log.output_file;
  if fname =: '/usr/sas/SASApp_STPServer' then call execute ('%log_analysis;');
else put 'no log files';
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With this code, I'm calling the macro based on the filename. Instead of that,&amp;nbsp;I need to create a macro and then pass file names as argument.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Although I've referred the example 2 from the following,I could not suceed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P align="left"&gt;&lt;A href="https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm" target="_blank"&gt;&lt;FONT face="Calibri,Calibri" size="3"&gt;&lt;SPAN&gt;https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000210819.htm&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;&lt;P align="left"&gt;&amp;nbsp;&lt;/P&gt;&lt;P align="left"&gt;Kindly seeking someon'e help to achive this task.&lt;/P&gt;&lt;P align="left"&gt;&amp;nbsp;&lt;/P&gt;&lt;P align="left"&gt;Thanks!&lt;/P&gt;&lt;P align="left"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2015 06:10:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/227996#M41128</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2015-10-01T06:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass file names as macro prameters?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228001#M41129</link>
      <description>&lt;P&gt;If I have understood it properly, you want to use a macro with a parameter. To do that you must do something like that&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%macro import_file(parameter1);
&lt;BR /&gt;*to use it you must do something like that;
"&amp;amp;path/&amp;amp;parameter1..TXT";

%mend;&lt;BR /&gt;&lt;BR /&gt;%import_file(TEST);&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%macro import_file(parameter1=);

*to use it you must do something like that;
"&amp;amp;path/&amp;amp;parameter1..TXT";

%mend;&lt;BR /&gt;&lt;BR /&gt;%import_file(parameter1=TEST);&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;They look really similar, the first if you put multiples parameters, they must be given in the same order of the definition. In the second you could give values to parameter without matter about the order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I recomend use the second one, because if you have a macro with 10 parameters is very difficult to remmember order.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2015 06:42:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228001#M41129</guid>
      <dc:creator>arodriguez</dc:creator>
      <dc:date>2015-10-01T06:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass file names as macro prameters?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228003#M41131</link>
      <description>&lt;P&gt;In your second example, how will you give the filenames to parameter without hardcoding?&amp;nbsp;Can't we get the file reference and file name from .txt file and pass it to the macro parameter?&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2015 06:50:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228003#M41131</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2015-10-01T06:50:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass file names as macro prameters?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228004#M41132</link>
      <description>&lt;P&gt;You mean how to give a array of files to import and avoid to execute proc import for each parameter? You could define a character as separator of the array (I use to use # because sometimes files have spaces in names).&lt;/P&gt;
&lt;P&gt;Uou could do something like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro import_files(File_names=);

%local i actual_file;
%do i=1 %to %sysfunc(countw(&amp;amp;File_names));
  %let actual_file=%scan(&amp;amp;File_names,&amp;amp;i,%str(#));&lt;BR /&gt;  *Now you have a parameter Actual_file with the i-th file that could be use as macro parameter in a&lt;BR /&gt;  data _null_ or proc import;


%end;

%mend;&lt;BR /&gt;&lt;BR /&gt;%import_files(File_names=File1#File2#OtherFile);&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2015 07:04:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228004#M41132</guid>
      <dc:creator>arodriguez</dc:creator>
      <dc:date>2015-10-01T07:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass file names as macro prameters?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228006#M41133</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your coninued support.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can import the file via data step and I've the code to do that. I need to pass file names as parameter while I reading the file to create a dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the code below, could you please tell me the folder where it will search for the file?&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2015 07:13:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228006#M41133</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2015-10-01T07:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass file names as macro prameters?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228007#M41134</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro import_files(File_names=);

%local i actual_file;
%do i=1 %to %sysfunc(countw(&amp;amp;File_names));
  %let actual_file=%scan(&amp;amp;File_names,&amp;amp;i,%str(#));  *Now you have a parameter Actual_file with the i-th file that could be use as macro parameter in a  data _null_ or proc import;

data log.output_file ;
  infile "&amp;amp;path/&amp;amp;actual_file..txt" firstobs=2 truncover ;
  input fname $400. ;
run;

%end;

%mend;%import_files(File_names=File1#File2#OtherFile);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I think that you want to do something like that, since it use the &amp;amp;path macro variable, it depend on want you put in this macro var&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2015 07:19:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228007#M41134</guid>
      <dc:creator>arodriguez</dc:creator>
      <dc:date>2015-10-01T07:19:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass file names as macro prameters?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228009#M41136</link>
      <description>&lt;P&gt;From the following line, it seems you're hard coding the file names.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%import_files(File_names=File1#File2#OtherFile);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If so, I would like to have a macro without any hardcoding.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2015 08:10:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228009#M41136</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2015-10-01T08:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass file names as macro prameters?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228011#M41137</link>
      <description>&lt;P&gt;You coud use the macro of &lt;A href="http://support.sas.com/kb/45/805.html" target="_blank"&gt;http://support.sas.com/kb/45/805.html&lt;/A&gt; This macro search all files in a directory&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%macro drive(dir,ext); 

	%local filrf rc did memcnt name;
                                                                                                                                        
  %let filrf=mydir;                                                                                                                      
                                                                                                                                        
  /* Assigns the fileref of mydir to the directory and opens the directory */                                                                    
  %let rc=%sysfunc(filename(filrf,&amp;amp;dir));                                                                                                
  %let did=%sysfunc(dopen(&amp;amp;filrf));                                                                                                              
  /* Returns the number of members in the directory */                                                                   
  %let memcnt=%sysfunc(dnum(&amp;amp;did));                                                                                                      
                                                                                                                                        
   /* Loops through entire directory */                                                                                                  
   %do i = 1 %to &amp;amp;memcnt;                                                                                                                
    
     /* Returns the extension from each file */                                                                                                                                    
     %let name=%qscan(%qsysfunc(dread(&amp;amp;did,&amp;amp;i)),-1,.);                                                                                   
                                                                                                                                        
     /* Checks to see if file contains an extension */                                                                                     
     %if %qupcase(%qsysfunc(dread(&amp;amp;did,&amp;amp;i))) ne %qupcase(&amp;amp;name) %then %do;                                                                  
                                                                                                                                        
     /* Checks to see if the extension matches the parameter value */                                                                      
     /* If condition is true prints the full name to the log       */                                                                      
      %if (%superq(ext) ne and %qupcase(&amp;amp;name) = %qupcase(&amp;amp;ext)) or                                                                       
         (%superq(ext) = and %superq(name) ne) %then %do;                                                                                     
         		%qsysfunc(dread(&amp;amp;did,&amp;amp;i))                  
      %end;                                                                               
     %end;                                                                                                                               
   %end;                                                                                                                                                                                                                                                                   
  /* Closes the directory  */                                                                                                            
  %let rc=%sysfunc(dclose(&amp;amp;did));                                                                                                        
                                                                                                                                        
%mend drive; 

%let FILES=%drive(&amp;amp;path);;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This macro return names separated by spaces not by #, so adapt the file &lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2015 08:32:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228011#M41137</guid>
      <dc:creator>arodriguez</dc:creator>
      <dc:date>2015-10-01T08:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass file names as macro prameters?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228012#M41138</link>
      <description>&lt;P&gt;Thanks a ton.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I'm not wrong, I need to place the code at the begining, before I call the macro %log_analysis from my intial post. I think this time I need to call that macro with parameters something like below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;macro %log_analysis (&amp;amp;files);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Am I right?&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2015 08:50:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228012#M41138</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2015-10-01T08:50:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass file names as macro prameters?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228013#M41139</link>
      <description>yes, something like &lt;BR /&gt;%macro %log_analysis(parameter1=&amp;amp;files);</description>
      <pubDate>Thu, 01 Oct 2015 08:56:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228013#M41139</guid>
      <dc:creator>arodriguez</dc:creator>
      <dc:date>2015-10-01T08:56:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass file names as macro prameters?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228026#M41141</link>
      <description>&lt;P&gt;One of the nice features of SAS macros is that you can define parameters as positional and still call them by name. &amp;nbsp;You just can't do the reverse.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if I had a macro defined like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro divide(numerator,denominator);
...
%mend divide;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I could call it many ways:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%divide(10,5);
%divide(numerator=10,denominator=5);
%divide(denominator=5,numerator=10);
%divide(10,denominator=5);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Oct 2015 12:51:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228026#M41141</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-10-01T12:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass file names as macro prameters?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228037#M41142</link>
      <description>&lt;P&gt;Does this get you what you are looking for?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;select distinct memname into :namelist separated by ' '&lt;BR /&gt;from dictionary.columns&lt;BR /&gt;where libname = 'WORK' and memname ne '_PRODSAVAIL';&lt;BR /&gt;&lt;BR /&gt;%put &amp;amp;namelist;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2015 13:28:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228037#M41142</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-10-01T13:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass file names as macro prameters?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228232#M41207</link>
      <description>I agree with you Tom.&lt;BR /&gt;&lt;BR /&gt;However intially I don't know to dynamically pass the filenames as per my initial. I.e. without hardcoding the macro parameter values like yours.&lt;BR /&gt;&lt;BR /&gt;You have any other solutions for my intial post before I try the solution suggested by others?&lt;BR /&gt;</description>
      <pubDate>Fri, 02 Oct 2015 16:11:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228232#M41207</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2015-10-02T16:11:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass file names as macro prameters?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228237#M41211</link>
      <description>&lt;P&gt;I really am not sure I understand the original question. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have an existing piece of code and you want to change to a macro with parameters then just additify the pieces that change and make them parameters. Then in the code replace the original hardcoded text with the macro variable reference to the parameter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if you are talking about the adding a parameter to your original macro then the change should look like this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro log_analysis(filename);

data log.log_analysis;
  length fname $400;
   infile "&amp;amp;filename" dsd truncover END = end_of_file LRECL=32000;
   fname="&amp;amp;filename" ;
  DO WHILE (not end_of_file);
    input var : $ 3000.;
..........
..........
%mend log_analysis;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now this program will have a problem when called multiple times since the name of the data set is now hard coded. &amp;nbsp;But you could also convert that to a parameter. &amp;nbsp;Or you could add more complex logic to read thie current file and then append the result to a master dataset that would accumulate the data over multiple macro calls.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2015 16:51:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228237#M41211</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-10-02T16:51:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass file names as macro prameters?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228312#M41232</link>
      <description>Thanks for your prompt reply.&lt;BR /&gt;&lt;BR /&gt;May I request you to tell me to append the datasets after I modify the datasets names as parameters? E.g. I will get three datasets if the macro is called three times. How to append these three datasets as one master dataset?</description>
      <pubDate>Sat, 03 Oct 2015 03:48:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228312#M41232</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2015-10-03T03:48:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass file names as macro prameters?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228317#M41236</link>
      <description>&lt;P&gt;I would use PROC APPEND.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro log_analysis
(filename    /* Physical name of input file */
,data=work.log_analysis /* Name of SAS dataset */
,base=log.log_analysis /* Name of the Master dataset */
);

data &amp;amp;data;
  length fname $400;
   infile "&amp;amp;filename" dsd truncover END = end_of_file LRECL=32000;
   fname="&amp;amp;filename" ;
...
run;

proc append data=&amp;amp;data base=&amp;amp;base force;
run;
%mend log_analysis;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 03 Oct 2015 11:56:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228317#M41236</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-10-03T11:56:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass file names as macro prameters?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228346#M41245</link>
      <description>How does the macro variable &amp;amp;base will get resolve? Because it was declared in your example. &lt;BR /&gt;&lt;BR /&gt;Thanks again for your continued support.</description>
      <pubDate>Sun, 04 Oct 2015 09:37:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228346#M41245</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2015-10-04T09:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass file names as macro prameters?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228354#M41248</link>
      <description>&lt;P&gt;A macro variable gets resolve when you reference with &amp;amp;. &amp;nbsp;So %PUT &amp;amp;BASE will write the value of BASE to the log.&lt;/P&gt;
&lt;P&gt;A macro variable gets assigned a value in a number of ways.&lt;/P&gt;
&lt;P&gt;%let base=fred;&lt;/P&gt;
&lt;P&gt;... call symputx('base','fred'); ...&lt;/P&gt;
&lt;P&gt;... select 'fred' into :base ....&lt;/P&gt;
&lt;P&gt;In the context of call a macro the parmeters (which are really just macro variables that are local to the macro) the value assigned is based on how you call it. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you specify a value on the macro call , %mymacro(base=fred), then that is the value assigned.&lt;/P&gt;
&lt;P&gt;If have defined it with a default value in the macro definition then if you call the macro wihout specifying a value it will use the defualt value.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro mymacro(base=george); %put &amp;amp;base; %mend mymacro;

 %mymacro; 
 george
 %mymacro(base=fred);
 fred
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to override the default and&amp;nbsp;set the value to an empty string then include it in the macro call. %mymacro(base=);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Oct 2015 19:24:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228354#M41248</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-10-04T19:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass file names as macro prameters?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228411#M41267</link>
      <description>&lt;P&gt;I've another question. How will you pass values to the maco paramter 'filename'? I need to pass values from the other macro (filelist)&amp;nbsp;to the macro parameter 'filename' instead of explicitly defining the values. I did tried like below,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In&amp;nbsp;the code below,filename resolves to SASApp_STPServer_2015-10-01_18208.lo​g and SASApp_STPServer_2015-10-04_tmptcmsaslva2_19142.lo​g. These two .log files are different file and I was expecting SAS to process the file one-by-one and then need to consolidate to one master dataset log.log_analysis. When I ran the code below, SAS was trying to&amp;nbsp;search both the file at the same moment and it failed as it could not find both the file in a single data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select distinct fname into :filelist separated by ' '
from log.output_file;
quit;

%put &amp;amp;filelist;


%macro log_analysis
(filename =&amp;amp;filelist  /* Physical name of input file */
,data=work.log_analysis /* Name of SAS dataset */
,base=log.log_analysis /* Name of the Master dataset */
);

data &amp;amp;data;
set log.output_file;
length fname $400;
infile "/usr/sas/sas_config/Lev1/SASApp/StoredProcessServ​er/Logs/&amp;amp;filename" dsd truncover  END = end_of_file LRECL=32000;
fname="&amp;amp;filename" ;
DO WHILE (not end_of_file);
input var : $ 3000.;
var1 = _infile_;
if var1 = :'201' then do;
...........
...........
output;
end;
end;
run;

proc append data=&amp;amp;data base=&amp;amp;base force;
run;

%mend log_analysis;

data _null_;
  set log.output_file;
  if fname =: 'SASApp_STPServer' then call execute ('%log_analysis;');
else put 'no log files';
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;you guide me how to achive this task? Please be informed that the macro filelist is also resolves to SASApp_STPServer_2015-10-01_tmptcmsaslva2_18208.lo​g and SASApp_STPServer_2015-10-04_tmptcmsaslva2_19142.lo​g&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
NOTE: CALL EXECUTE generated line.
1         + data work.log_analysis;  set log.output_file;    length fname $400;  infile 
"/usr/sas/sas_config/Lev1/SASApp/StoredProcessServ​er/Logs/SASApp_STPServer_2015-10-01_18208.log 
SASApp_STPServer_2015-10-04_19142.log" dsd truncover
2         + END = end_of_file LRECL=32000;  fname="SASApp_STPServer_2015-10-01_tmptcmsaslva2_1​8208.log 
SASApp_STPServer_2015-10-04_19142.log" ;  DO WHILE (not end_of_file);  input var : $ 3000.;    var1 = _infile_;  if 
var1 = :'201' then do;
3         + Date_TimeStamp= scan(var1,1," ");  Status = scan(var1,2," ");  Processid = scan(var1,3," ");  userid = scan(var1,4," 
");  Details = scan(var1,-1,'-');  output;  end;  end;  drop var var1;  run;

ERROR: Physical file does not exist, 
       /usr/sas/sas_config/Lev1/SASApp/StoredProcessServe​r/Logs/SASApp_STPServer_2015-10-01_18208.log 
       SASApp_STPServer_2015-10-04_19142.log.
NOTE: The SAS System stopped processing this step because of errors.
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks for any help you offer me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Oct 2015 13:05:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-file-names-as-macro-prameters/m-p/228411#M41267</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2015-10-05T13:05:38Z</dc:date>
    </item>
  </channel>
</rss>

