<?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: Pass CSV file to Macro in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-CSV-file-to-Macro/m-p/446768#M28895</link>
    <description>&lt;P&gt;First problem: you need a semicolon at the end of the %macro statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%MACRO Operation(MyFile);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second problem: Too many double quotes. Changing these lines as shown will work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA WORK.&amp;amp;MyFile; *file name should come without extension;&lt;/P&gt;
&lt;P&gt;INFILE '/sas/FLATFILES/LEAD/&amp;amp;MyFile' * Path of the file should come with extension;&lt;/P&gt;
&lt;P&gt;%Operation(MyFile.csv);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Third problem: In line&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA WORK.&amp;amp;MyFile; *file name should come without extension;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;amp;Myfile is resolving to testfile.txt, which means that your SAS dataset name is work.testfile.txt, which is illegal. Easiest solution is add another macro parameter for the SAS file name:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%MACRO Operation(MyFile, MySASFile);&lt;/P&gt;
&lt;P&gt;DATA WORK.&amp;amp;MySASFile; *file name should come without extension;&lt;/P&gt;
&lt;P&gt;%Operation(&lt;SPAN&gt;MyFile.csv&lt;/SPAN&gt;, &lt;SPAN&gt;MyFile&lt;/SPAN&gt;);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Fourth problem: You need to use double quotes for macro variables to resolve:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;INFILE "&lt;SPAN&gt;/sas/FLATFILES/LEAD/&amp;amp;MyFile&lt;/SPAN&gt;"&amp;nbsp;* Path of the file should come with extension;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Fifth problem: Your comment on the INFILE statement is before the semicolon, so it's being picked up as SAS code. You should remove it, or put it after the semicolon:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;INFILE "&lt;SPAN&gt;/sas/FLATFILES/LEAD/&amp;amp;MyFile&lt;/SPAN&gt;"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This should move the yardstick for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
    <pubDate>Mon, 19 Mar 2018 13:52:21 GMT</pubDate>
    <dc:creator>TomKari</dc:creator>
    <dc:date>2018-03-19T13:52:21Z</dc:date>
    <item>
      <title>Pass CSV file to Macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-CSV-file-to-Macro/m-p/446663#M28893</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working EG and i'm trying to pass one csv file to the macro but it is not working Here is my code below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%MACRO Operation(MyFile)&lt;BR /&gt;DATA WORK."&amp;amp;MyFile"; *file name should come without extension;&lt;BR /&gt;LENGTH&lt;BR /&gt;Name $ 100&lt;BR /&gt;MOBNO $ 20&lt;BR /&gt;PhoneNo $ 20&lt;BR /&gt;STATE $ 100&lt;BR /&gt;CITY $ 100&lt;/P&gt;&lt;P&gt;FORMAT&lt;BR /&gt;Name $CHAR100.&lt;BR /&gt;MOBNO $CHAR20.&lt;BR /&gt;PhoneNo $CHAR20.&lt;BR /&gt;STATE $CHAR100.&lt;BR /&gt;CITY $CHAR100.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;INFORMAT&lt;BR /&gt;Name $CHAR100.&lt;BR /&gt;MOBNO $CHAR20.&lt;BR /&gt;PhoneNo $CHAR20.&lt;BR /&gt;STATE $CHAR100.&lt;BR /&gt;CITY $CHAR100.&lt;/P&gt;&lt;P&gt;INFILE '/sas/FLATFILES/LEAD/"&amp;amp;MyFile"' * Path of the file should come with extension;&lt;BR /&gt;/* LRECL=499&lt;BR /&gt;ENCODING="UTF-8"&lt;BR /&gt;TERMSTR=CRLF */&lt;BR /&gt;DLM='|'&lt;BR /&gt;MISSOVER&lt;BR /&gt;DSD&lt;BR /&gt;FIRSTOBS=2;&lt;BR /&gt;INPUT&lt;BR /&gt;Name : $CHAR100.&lt;BR /&gt;MOBNO : $CHAR20.&lt;BR /&gt;PhoneNo : $CHAR20.&lt;BR /&gt;STATE : $CHAR100.&lt;BR /&gt;CITY : $CHAR100.&lt;/P&gt;&lt;P&gt;RUN;&lt;BR /&gt;%MEND;&lt;/P&gt;&lt;P&gt;%Operation("MyFile.csv");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;please if you have any suggestion&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 03:32:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-CSV-file-to-Macro/m-p/446663#M28893</guid>
      <dc:creator>ramanandyadav</dc:creator>
      <dc:date>2018-03-19T03:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: Pass CSV file to Macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-CSV-file-to-Macro/m-p/446768#M28895</link>
      <description>&lt;P&gt;First problem: you need a semicolon at the end of the %macro statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%MACRO Operation(MyFile);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second problem: Too many double quotes. Changing these lines as shown will work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA WORK.&amp;amp;MyFile; *file name should come without extension;&lt;/P&gt;
&lt;P&gt;INFILE '/sas/FLATFILES/LEAD/&amp;amp;MyFile' * Path of the file should come with extension;&lt;/P&gt;
&lt;P&gt;%Operation(MyFile.csv);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Third problem: In line&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA WORK.&amp;amp;MyFile; *file name should come without extension;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;amp;Myfile is resolving to testfile.txt, which means that your SAS dataset name is work.testfile.txt, which is illegal. Easiest solution is add another macro parameter for the SAS file name:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%MACRO Operation(MyFile, MySASFile);&lt;/P&gt;
&lt;P&gt;DATA WORK.&amp;amp;MySASFile; *file name should come without extension;&lt;/P&gt;
&lt;P&gt;%Operation(&lt;SPAN&gt;MyFile.csv&lt;/SPAN&gt;, &lt;SPAN&gt;MyFile&lt;/SPAN&gt;);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Fourth problem: You need to use double quotes for macro variables to resolve:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;INFILE "&lt;SPAN&gt;/sas/FLATFILES/LEAD/&amp;amp;MyFile&lt;/SPAN&gt;"&amp;nbsp;* Path of the file should come with extension;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Fifth problem: Your comment on the INFILE statement is before the semicolon, so it's being picked up as SAS code. You should remove it, or put it after the semicolon:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;INFILE "&lt;SPAN&gt;/sas/FLATFILES/LEAD/&amp;amp;MyFile&lt;/SPAN&gt;"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This should move the yardstick for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 13:52:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-CSV-file-to-Macro/m-p/446768#M28895</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2018-03-19T13:52:21Z</dc:date>
    </item>
  </channel>
</rss>

