<?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: Macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/369022#M88033</link>
    <description>&lt;P&gt;In addition to what everyone else has stated - double quotes are needed on the path.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And just a note, you don't need a macro to import multiple text files.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the approach here or use the filevar to specify the file name&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/ta-p/223627" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/ta-p/223627&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Jun 2017 06:20:06 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-06-21T06:20:06Z</dc:date>
    <item>
      <title>Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/369017#M88029</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to import csv files named Tran.1_28May17 upto Tran.37_28May17 within a macro:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro onetime;&lt;BR /&gt;%local i;&lt;BR /&gt;%do i=1 %to 37 %by 1;&lt;/P&gt;&lt;P&gt;DATA temp_&amp;amp;i;&lt;BR /&gt;INFILE '/folders/myfolders/sasuser.v94/tran.&amp;amp;i_28MAY17.csv' DSD delimiter=',' missover firstobs=2;&lt;BR /&gt;informat Date Date. Credit 8.2 Debit 8.2;&lt;BR /&gt;FORMAT Date :DATE. Credit dollar.0 Debit dollar.0;&lt;BR /&gt;INPUT&lt;BR /&gt;Account :$8.&lt;BR /&gt;Tran_Code :$4.&lt;BR /&gt;Date&lt;BR /&gt;Credit&lt;BR /&gt;Debit&lt;BR /&gt;Desc :$100.&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;BR /&gt;end;&lt;BR /&gt;%mend onetime;&lt;BR /&gt;%onetime;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However get the following error message...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="sasSource"&gt;1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;61&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;62&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;63 %macro onetime;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;64 %local i;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;65 %do i=1 %to 38 %by 1;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;66&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;67&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;68&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;69 DATA temp_&amp;amp;i;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;70 INFILE '/folders/myfolders/sasuser.v94/tran.&amp;amp;i_28MAY17.csv' DSD delimiter=',' missover firstobs=2;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;71 informat Date Date. Credit 8.2 Debit 8.2;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;72 FORMAT Date :DATE. Credit dollar.0 Debit dollar.0;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;73 INPUT&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;74 Account:$8.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;75 Tran_Code :$4.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;76 Date&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;77 Credit&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;78 Debit&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;79 Desc :$100.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;80 ;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;81 RUN;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;82 end;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;83 %mend onetime;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR: There were 1 unclosed %DO statements. The macro ONETIME will not be compiled.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR: A dummy macro will be compiled.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;84 %onetime;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;_&lt;/DIV&gt;&lt;DIV class="sasError"&gt;180&lt;/DIV&gt;&lt;DIV class="sasWarning"&gt;WARNING: Apparent invocation of macro ONETIME not resolved.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;85&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;86 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;How do I solve this?&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;thanks&lt;/DIV&gt;</description>
      <pubDate>Wed, 21 Jun 2017 06:03:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/369017#M88029</guid>
      <dc:creator>Selli5</dc:creator>
      <dc:date>2017-06-21T06:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/369018#M88030</link>
      <description>&lt;P&gt;You are missing an % in front of your end. It should be %end below your RUN statement.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2017 06:06:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/369018#M88030</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-06-21T06:06:26Z</dc:date>
    </item>
    <item>
      <title>Re: Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/369020#M88031</link>
      <description>&lt;P&gt;This:&lt;/P&gt;
&lt;PRE&gt;ERROR: There were 1 unclosed %DO statements. &lt;/PRE&gt;
&lt;P&gt;says it all. Any %do needs a corresponding %end.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro onetime;
%local i;
%do i=1 %to 37 %by 1;

data temp_&amp;amp;i;
infile
  '/folders/myfolders/sasuser.v94/tran.&amp;amp;i_28MAY17.csv'
  dsd
  delimiter=','
  missover
  firstobs=2
;
informat
  Date Date.
  Credit 8.2
  Debit 8.2
;
format
  Date date.
  Credit dollar.0
  Debit dollar.0
;
input
  Account :$8.
  Tran_Code :$4.
  Date
  Credit
  Debit
  Desc :$100.
;
run;

%end; /* error was here, was "end" without macro trigger % */
%mend onetime;
%onetime;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And note how a little visual formatting makes the code more readable (Maxim 12).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, if you restructure your filenames to something that makes hierarchical sense:&lt;/P&gt;
&lt;PRE&gt;tran_2017-05-28_01.csv
tran_2017-05-28_02.csv
....
tran_2017-05-28_37.csv&lt;/PRE&gt;
&lt;P&gt;you could avoid all the hassle and use wildcards in a single data step (Maxim 33), removing the need for macro programming.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2017 06:14:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/369020#M88031</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-06-21T06:14:43Z</dc:date>
    </item>
    <item>
      <title>Re: Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/369022#M88033</link>
      <description>&lt;P&gt;In addition to what everyone else has stated - double quotes are needed on the path.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And just a note, you don't need a macro to import multiple text files.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the approach here or use the filevar to specify the file name&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/ta-p/223627" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/ta-p/223627&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2017 06:20:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/369022#M88033</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-21T06:20:06Z</dc:date>
    </item>
    <item>
      <title>Re: Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/369023#M88034</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;In addition to what everyone else has stated - double quotes are needed on the path.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Good catch. Totally overlooked that.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2017 06:21:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/369023#M88034</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-06-21T06:21:06Z</dc:date>
    </item>
  </channel>
</rss>

