<?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: Help with macro function in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Help-with-macro-function/m-p/155235#M40758</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure why all the &amp;amp;&amp;amp;'s are needed, you could do something like:&lt;/P&gt;&lt;P&gt;filename my_dir pipe 'dir "c:\temp\*.txt" /b';&amp;nbsp; /* Note change to unix - this is Win */&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length buffer $2000.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile my_dir;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if my_dir="2015.02.04 Complete XYZ Data.txt" then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('data '||compress(buffer,' .1234567890')||';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile "'||sstrip(buffer)||'";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input...;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;');&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or just use wildcards in the infile if you are ok with it all in one dataset.&amp;nbsp; I tend to find when there's lots of &amp;amp; and %'s all over things are bound to go wrong.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 05 Feb 2015 15:56:47 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2015-02-05T15:56:47Z</dc:date>
    <item>
      <title>Help with macro function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Help-with-macro-function/m-p/155234#M40757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to read the text file on UNIX using infile. Below is the part of the code:&amp;nbsp;&amp;nbsp; %if &amp;amp;&amp;amp;file&amp;amp;j.. =&amp;nbsp; %str(2015.02.04 Complete XYZ Data.txt)&amp;nbsp; %then&amp;nbsp; %do;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data&amp;nbsp; rawdata;&amp;nbsp;&amp;nbsp; infile fromunix(%sysfunc(cats(&amp;amp;&amp;amp;file&amp;amp;j..)))&amp;nbsp; dlm="|"&amp;nbsp; dsd truncover lrecl=32707 firstobs=2;&amp;nbsp;&amp;nbsp; %end; But somehow macro does not work mainly because there are periods and spaces for the file name.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If there is no period or space then it works. Is there a macro function I can use to make the above thing work with spaces and periods in the name of the file?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2015 15:47:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Help-with-macro-function/m-p/155234#M40757</guid>
      <dc:creator>pp2014</dc:creator>
      <dc:date>2015-02-05T15:47:53Z</dc:date>
    </item>
    <item>
      <title>Re: Help with macro function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Help-with-macro-function/m-p/155235#M40758</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure why all the &amp;amp;&amp;amp;'s are needed, you could do something like:&lt;/P&gt;&lt;P&gt;filename my_dir pipe 'dir "c:\temp\*.txt" /b';&amp;nbsp; /* Note change to unix - this is Win */&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length buffer $2000.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile my_dir;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if my_dir="2015.02.04 Complete XYZ Data.txt" then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('data '||compress(buffer,' .1234567890')||';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile "'||sstrip(buffer)||'";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input...;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;');&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or just use wildcards in the infile if you are ok with it all in one dataset.&amp;nbsp; I tend to find when there's lots of &amp;amp; and %'s all over things are bound to go wrong.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2015 15:56:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Help-with-macro-function/m-p/155235#M40758</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-02-05T15:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: Help with macro function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Help-with-macro-function/m-p/155236#M40759</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can get a better appearing post by copying your text into a simple text editor like Notepad before posting here. (Also find the suggestion for the form to get an editor that accepts enhanced program editor code better and vote for it)&lt;/P&gt;&lt;P&gt;Is there any particular reason you are using %sysfunct and CATS?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When it comes to working with macros and files I tend to make file references to read data so the INFILE lines are simpler and the filename statement will tell me if the file was successfully assigned.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From what I see of your code you might actually be wanting&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Filename fromunix "&amp;amp;&amp;amp;file&amp;amp;j"; &lt;/P&gt;&lt;P&gt;and then the Infile would be&lt;/P&gt;&lt;P&gt;infile fromunix&amp;nbsp; dlm="|"&amp;nbsp; dsd truncover lrecl=32707 firstobs=2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you were getting errors you should run the code with OPTIONS MPRINT SYMBOLGEN and include that with the errors from the log.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2015 16:06:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Help-with-macro-function/m-p/155236#M40759</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-02-05T16:06:42Z</dc:date>
    </item>
    <item>
      <title>Re: Help with macro function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Help-with-macro-function/m-p/155237#M40760</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi RW9, Thanks for the solution.&amp;nbsp; I tried it but it does not seem to work. Below is my code without macro which runs on UNIX.&amp;nbsp;&amp;nbsp; The zipped file has 2015.02.04 Complete XYZ Data.txt file in it.&amp;nbsp; When I run the below code I get the filenm variable with value = 2015.02.04 and not the full file name.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I tried your code but somehow it gives me error.&amp;nbsp; Can you please let me know how do I make it work on UNIX? Thanks a lot&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;filename xx pipe "zipinfo -1&amp;nbsp;&amp;nbsp; /PROD/in/2015.02.04_Complete_XYZ_Data.zip"; &lt;/P&gt;&lt;P&gt;data check;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;infile xx ;&lt;/P&gt;&lt;P&gt;length filenm $45;&amp;nbsp; &lt;/P&gt;&lt;P&gt;input filenm $; &lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2015 18:26:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Help-with-macro-function/m-p/155237#M40760</guid>
      <dc:creator>pp2014</dc:creator>
      <dc:date>2015-02-05T18:26:23Z</dc:date>
    </item>
    <item>
      <title>Re: Help with macro function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Help-with-macro-function/m-p/155238#M40761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was able to figure it out.&amp;nbsp; I had to use dlm='09'x in the infile statement&amp;nbsp; and then it worked...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2015 18:54:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Help-with-macro-function/m-p/155238#M40761</guid>
      <dc:creator>pp2014</dc:creator>
      <dc:date>2015-02-05T18:54:29Z</dc:date>
    </item>
  </channel>
</rss>

