<?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: batch process data files with contionout file names in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/batch-process-data-files-with-contionout-file-names/m-p/244823#M45660</link>
    <description>&lt;P&gt;A loop like that is possible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you know what the rest of the DATA step would look like?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do all the .csv files have the same structure?&lt;/P&gt;</description>
    <pubDate>Wed, 20 Jan 2016 21:21:53 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-01-20T21:21:53Z</dc:date>
    <item>
      <title>batch process data files with contionout file names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/batch-process-data-files-with-contionout-file-names/m-p/244805#M45652</link>
      <description>&lt;P&gt;I have 12 files, file name like "xxxx201501.csv", "xxxx201502.csv", ... "xxxx201512.csv"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if I want to do the same opration on them, can I use a loop and macro varaible to do it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2016 19:59:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/batch-process-data-files-with-contionout-file-names/m-p/244805#M45652</guid>
      <dc:creator>fengyuwuzu</dc:creator>
      <dc:date>2016-01-20T19:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: batch process data files with contionout file names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/batch-process-data-files-with-contionout-file-names/m-p/244807#M45653</link>
      <description>&lt;P&gt;Yes, look into Call Execute.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2016 20:03:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/batch-process-data-files-with-contionout-file-names/m-p/244807#M45653</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-20T20:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: batch process data files with contionout file names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/batch-process-data-files-with-contionout-file-names/m-p/244809#M45654</link>
      <description>&lt;P&gt;What do you already know how to do with these 12 names?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Issue a system command to display the names?&lt;/LI&gt;
&lt;LI&gt;Get the names of the files into a text file?&lt;/LI&gt;
&lt;LI&gt;Get the names of the files into a SAS data set?&lt;/LI&gt;
&lt;LI&gt;Nothing?&amp;nbsp; (In that case, we might need to know the operating system.)&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Yes, you certainly can create a macro and loop through the names.&amp;nbsp; But depending on what you want to do with them, a macro might not even be necessary.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2016 20:19:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/batch-process-data-files-with-contionout-file-names/m-p/244809#M45654</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-01-20T20:19:22Z</dc:date>
    </item>
    <item>
      <title>Re: batch process data files with contionout file names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/batch-process-data-files-with-contionout-file-names/m-p/244810#M45655</link>
      <description>for example, I want to read in these 12 files and output 12 new files: &lt;BR /&gt;data work.datast01;&lt;BR /&gt;infile "xxxx201501.csv" ...;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 20 Jan 2016 20:37:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/batch-process-data-files-with-contionout-file-names/m-p/244810#M45655</guid>
      <dc:creator>fengyuwuzu</dc:creator>
      <dc:date>2016-01-20T20:37:37Z</dc:date>
    </item>
    <item>
      <title>Re: batch process data files with contionout file names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/batch-process-data-files-with-contionout-file-names/m-p/244812#M45656</link>
      <description>&lt;P&gt;If macro language could get you the right INFILE statements, would you know how to write the INPUT statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is your ultimate goal 12 separate SAS data sets, or 1 large SAS data set combining all the data from the 12 files?&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2016 20:44:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/batch-process-data-files-with-contionout-file-names/m-p/244812#M45656</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-01-20T20:44:58Z</dc:date>
    </item>
    <item>
      <title>Re: batch process data files with contionout file names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/batch-process-data-files-with-contionout-file-names/m-p/244814#M45657</link>
      <description>I want to have 12 output data sets &lt;BR /&gt;&lt;BR /&gt;I was thinking about a do loop, but I do not know how to replace the 01, 02, ... 12 with the count variable</description>
      <pubDate>Wed, 20 Jan 2016 20:50:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/batch-process-data-files-with-contionout-file-names/m-p/244814#M45657</guid>
      <dc:creator>fengyuwuzu</dc:creator>
      <dc:date>2016-01-20T20:50:42Z</dc:date>
    </item>
    <item>
      <title>Re: batch process data files with contionout file names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/batch-process-data-files-with-contionout-file-names/m-p/244820#M45658</link>
      <description>&lt;P&gt;OK.&amp;nbsp; Here are two specific tasks you will need to complete in order to take this further.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. What operating system command can take the names of all 12 files and put the names into a text file?&amp;nbsp; What does the text file look like?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. What program would it take to read in a single one of the files, and create a SAS data set from that single file?&amp;nbsp; No macro language is involved.&amp;nbsp; Hard-code everything needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2016 21:02:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/batch-process-data-files-with-contionout-file-names/m-p/244820#M45658</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-01-20T21:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: batch process data files with contionout file names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/batch-process-data-files-with-contionout-file-names/m-p/244821#M45659</link>
      <description>&lt;P&gt;The code below works. But only for files 01-09. &lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Is there a way to include 10, 11 and 12 in the same macro?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro run_me;
%let n=1;

%do %while (&amp;amp;n &amp;lt;= 9);
%let filein = xxxx20150&amp;amp;n..csv;

data output&amp;amp;n;
infile &amp;amp;filein;
&amp;lt;data step--&amp;gt;
run;

%let n=%eval(&amp;amp;n+1);
%end;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2016 21:21:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/batch-process-data-files-with-contionout-file-names/m-p/244821#M45659</guid>
      <dc:creator>fengyuwuzu</dc:creator>
      <dc:date>2016-01-20T21:21:39Z</dc:date>
    </item>
    <item>
      <title>Re: batch process data files with contionout file names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/batch-process-data-files-with-contionout-file-names/m-p/244823#M45660</link>
      <description>&lt;P&gt;A loop like that is possible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you know what the rest of the DATA step would look like?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do all the .csv files have the same structure?&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2016 21:21:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/batch-process-data-files-with-contionout-file-names/m-p/244823#M45660</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-01-20T21:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: batch process data files with contionout file names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/batch-process-data-files-with-contionout-file-names/m-p/244825#M45661</link>
      <description>&lt;P&gt;yes, they have the same structure. It is for the same data set in different months.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I inserted my code which was used to read a single file, and it worked. Now I need to think about how to include 10, 11 and 12 three files.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2016 21:24:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/batch-process-data-files-with-contionout-file-names/m-p/244825#M45661</guid>
      <dc:creator>fengyuwuzu</dc:creator>
      <dc:date>2016-01-20T21:24:10Z</dc:date>
    </item>
    <item>
      <title>Re: batch process data files with contionout file names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/batch-process-data-files-with-contionout-file-names/m-p/244829#M45662</link>
      <description>&lt;P&gt;OK, given that you can get the program to work for 1 file, here is a way to write the loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro run_me;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%local n n2;&lt;/P&gt;
&lt;P&gt;%do n=1 %to 12;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; %let n2 = %sysfunc(putn(&amp;amp;n, z2));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; data output&amp;amp;n2;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; infile "xxx2015&amp;amp;n2";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;
&lt;P&gt;%end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%mend run_me;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Clearly, it would be possible to add other parameters such as names that replace "output" and "xxx".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's your choice whether you want to name the outputs with or without leading zeros:&amp;nbsp; output&amp;amp;n2 vs. output&amp;amp;n&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2016 21:32:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/batch-process-data-files-with-contionout-file-names/m-p/244829#M45662</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-01-20T21:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: batch process data files with contionout file names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/batch-process-data-files-with-contionout-file-names/m-p/244833#M45663</link>
      <description>%sysfunc(putN(&amp;amp;n,z2) is the thing I was looking for.&lt;BR /&gt;&lt;BR /&gt;Thank you very much!</description>
      <pubDate>Wed, 20 Jan 2016 21:40:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/batch-process-data-files-with-contionout-file-names/m-p/244833#M45663</guid>
      <dc:creator>fengyuwuzu</dc:creator>
      <dc:date>2016-01-20T21:40:43Z</dc:date>
    </item>
  </channel>
</rss>

