<?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 do I resolve macro variables as part of pipedir in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-resolve-macro-variables-as-part-of-pipedir/m-p/348118#M80570</link>
    <description>&lt;P&gt;Thanks Ksharp! &amp;nbsp;It worked like a charm.&lt;/P&gt;</description>
    <pubDate>Fri, 07 Apr 2017 14:27:24 GMT</pubDate>
    <dc:creator>Ryanb2</dc:creator>
    <dc:date>2017-04-07T14:27:24Z</dc:date>
    <item>
      <title>How do I resolve macro variables as part of pipedir</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-resolve-macro-variables-as-part-of-pipedir/m-p/347958#M80504</link>
      <description>&lt;P&gt;I found the code below (originally without any of the macro code) that inventories directories and it's lightning quick. &amp;nbsp;I want to turn it into a macro so I can call it when I need it, but when I put the &amp;amp;path in place of the literal path it resolves as &amp;amp;path rather than inserting the path I called in the macro. &amp;nbsp;I tried switching the single and double quotes and it looks like &amp;amp;path resolves to the correct path but now the coding doesn't work (Stderr output: The specified path is invalid.). &amp;nbsp;It works perfectly when I just paste the path into the code. &amp;nbsp;What can I do to turn this into a macro?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro get_file_info(path); /* &lt;A href="http://support.sas.com/resources/papers/proceedings12/058-2012.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings12/058-2012.pdf&lt;/A&gt; */&lt;BR /&gt; filename pipedir pipe ' dir "I:\VRBIS\TransaxAchieve-UCD" /S' lrecl=5000;&lt;BR /&gt;/* filename pipedir pipe ' dir "&amp;amp;path" /S' lrecl=5000;*/&lt;BR /&gt; data indata;&lt;BR /&gt; infile pipedir truncover;&lt;BR /&gt; input line $char1000.;&lt;BR /&gt; length directory $1000;&lt;BR /&gt; retain directory;&lt;BR /&gt; if line =' ' or&lt;BR /&gt; index(upcase(line),'&amp;lt;DIR&amp;gt;') or&lt;BR /&gt; left(upcase(line))=:'VOLUME' then&lt;BR /&gt; delete;&lt;BR /&gt; if left(upcase(line))=:'DIRECTORY OF' then&lt;BR /&gt; directory=left(substr(line,index(upcase(line),'DIRECTORY OF')+12));&lt;BR /&gt; if left(upcase(line))=:'DIRECTORY OF' then&lt;BR /&gt; delete;&lt;BR /&gt; if input(substr(line,1,10),?? mmddyy10.) = . then&lt;BR /&gt; substr(line,1,10)='12/31/2999';&lt;BR /&gt; date=input(substr(line,1,10),?? mmddyy10.);&lt;BR /&gt; format date mmddyy10.;&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;proc sort data=indata;&lt;BR /&gt; by directory descending date;&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;data Directory_Summary(drop=i line);&lt;BR /&gt; set indata;&lt;BR /&gt; by directory;&lt;BR /&gt; length filename $75;&lt;BR /&gt; retain number_of_files_in_directory directory_size;&lt;BR /&gt; if first.directory then&lt;BR /&gt; do;&lt;BR /&gt; number_of_files_in_directory=input(scan(line,2,' '),32.);&lt;BR /&gt; directory_size=input(scan(line,4,' '),comma32.);&lt;BR /&gt; end;&lt;BR /&gt; file_size=input(scan(line,4,' '),comma32.);&lt;BR /&gt; filename=' ';&lt;BR /&gt; do i=5 to 100;&lt;BR /&gt; filename=trim(left(filename))||' '||scan(line,i,' ');&lt;BR /&gt; if scan(line,i,' ')=' ' then&lt;BR /&gt; leave;&lt;BR /&gt; end;&lt;BR /&gt; if index(upcase(line),'FILE(S)') then&lt;BR /&gt; delete;&lt;BR /&gt; if date ge '30DEC2999'd then&lt;BR /&gt; delete;&lt;BR /&gt; run;&lt;BR /&gt;%mend get_file_info;&lt;/P&gt;
&lt;P&gt;/*%include 'H:\SAS code\Directory_summary.sas';*/&lt;BR /&gt;%get_file_info(I:\VRBIS\TransaxAchieve-UCD);&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 23:29:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-resolve-macro-variables-as-part-of-pipedir/m-p/347958#M80504</guid>
      <dc:creator>Ryanb2</dc:creator>
      <dc:date>2017-04-06T23:29:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do I resolve macro variables as part of pipedir</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-resolve-macro-variables-as-part-of-pipedir/m-p/347960#M80505</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;I created your directory

Does this help

%macro get_file_info(path);

   filename pipedir pipe &amp;amp;path lrecl=5000;
   data _null_;
     infile pipedir;
     input;
     putlog _infile_;
   run;quit;
   filename pipedir clear;

%mend get_file_info;

%get_file_info('dir d:\VRBIS\TransaxAchieve-UCD /S');


 Directory of d:\VRBIS\TransaxAchieve-UCD

04/06/2017  07:45 PM    &amp;lt;DIR&amp;gt;          .
04/06/2017  07:45 PM    &amp;lt;DIR&amp;gt;          ..
04/06/2017  07:45 PM           131,072 class1.sas7bdat
04/06/2017  07:45 PM           131,072 class2.sas7bdat
               2 File(s)        262,144 bytes

     Total Files Listed:
               2 File(s)        262,144 bytes
               2 Dir(s)  248,515,031,040 bytes free


&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Apr 2017 23:54:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-resolve-macro-variables-as-part-of-pipedir/m-p/347960#M80505</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2017-04-06T23:54:02Z</dc:date>
    </item>
    <item>
      <title>Re: How do I resolve macro variables as part of pipedir</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-resolve-macro-variables-as-part-of-pipedir/m-p/347962#M80506</link>
      <description>&lt;P&gt;Try reversing your quotes, switch the double with the single and single with double.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macro variables don't resolve in single quotes and your outer quotes are single.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro sample(path);

%put "This is my '&amp;amp;path'";

%mend;

%sample(This is the path);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Apr 2017 00:16:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-resolve-macro-variables-as-part-of-pipedir/m-p/347962#M80506</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-07T00:16:49Z</dc:date>
    </item>
    <item>
      <title>Re: How do I resolve macro variables as part of pipedir</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-resolve-macro-variables-as-part-of-pipedir/m-p/348083#M80556</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename pipedir pipe %sysfunc(quote( dir "&amp;amp;path" /S  )) lrecl=5000;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Apr 2017 13:29:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-resolve-macro-variables-as-part-of-pipedir/m-p/348083#M80556</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-04-07T13:29:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do I resolve macro variables as part of pipedir</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-resolve-macro-variables-as-part-of-pipedir/m-p/348116#M80568</link>
      <description>Thanks Roger.  I tried the code and for some reason it doesn't work.  It's error-free but it results in zero records read.  Thanks for the reply.</description>
      <pubDate>Fri, 07 Apr 2017 14:22:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-resolve-macro-variables-as-part-of-pipedir/m-p/348116#M80568</guid>
      <dc:creator>Ryanb2</dc:creator>
      <dc:date>2017-04-07T14:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do I resolve macro variables as part of pipedir</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-resolve-macro-variables-as-part-of-pipedir/m-p/348117#M80569</link>
      <description>Thanks Reeza.  I tried that earlier and the path does resolve but the code doesn't work the same.  The log indicates the path is invalid.</description>
      <pubDate>Fri, 07 Apr 2017 14:25:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-resolve-macro-variables-as-part-of-pipedir/m-p/348117#M80569</guid>
      <dc:creator>Ryanb2</dc:creator>
      <dc:date>2017-04-07T14:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do I resolve macro variables as part of pipedir</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-resolve-macro-variables-as-part-of-pipedir/m-p/348118#M80570</link>
      <description>&lt;P&gt;Thanks Ksharp! &amp;nbsp;It worked like a charm.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2017 14:27:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-resolve-macro-variables-as-part-of-pipedir/m-p/348118#M80570</guid>
      <dc:creator>Ryanb2</dc:creator>
      <dc:date>2017-04-07T14:27:24Z</dc:date>
    </item>
  </channel>
</rss>

