<?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 merging multiple CSV files to a dataset. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184808#M35075</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;After including &lt;STRONG&gt;%put &amp;amp;did;&lt;/STRONG&gt; into my syntax, I was indeed given a value of 0. What can I do to fix this?&lt;/P&gt;&lt;P&gt;- SMR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As a reminder, this is the error I receive for the syntax above&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;WARNING: Argument 1 to function DNUM referenced by the %SYSFUNC or %QSYSFUNC macro function is out&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; of range.&lt;/P&gt;&lt;P&gt;NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result of the operations have been set to a missing value.&lt;/P&gt;&lt;P&gt;0&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 25 Feb 2014 00:52:07 GMT</pubDate>
    <dc:creator>UT_Risom</dc:creator>
    <dc:date>2014-02-25T00:52:07Z</dc:date>
    <item>
      <title>Help merging multiple CSV files to a dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184804#M35071</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm attempting to merge 160 CSV files into one dataset using macros. All of the files have similar filenames (BTLT4-#####-#) and 167 column variables. I tried to use the syntax listed below to do this, but I'm given the following error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;WARNING: Argument 1 to function DNUM referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range. NOTE: Mathematical operations could not be performed during %SY&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help with this will be appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the syntax.&lt;/P&gt;&lt;P&gt;options mprint;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; %macro MultImp(dir=,out=);&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let rc=%sysfunc(filename(mydir,"&amp;amp;dir"));&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let did=%sysfunc(dopen(mydir));&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let lstname=;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let memcount=%sysfunc(dnum(&amp;amp;did));&lt;/P&gt;&lt;P&gt;&amp;nbsp; %if &amp;amp;memcount &amp;gt; 0 %then %do;mer&lt;/P&gt;&lt;P&gt;&amp;nbsp; %do i=1 %to &amp;amp;memcount;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let lstname=%sysfunc(dread(&amp;amp;did,&amp;amp;i));&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let file=&amp;amp;dir.&amp;amp;lstname;&lt;/P&gt;&lt;P&gt;&amp;nbsp; PROC IMPORT DBMS=CSV OUT= _&amp;amp;i&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; DATAFILE= "&amp;amp;file" REPLACE ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GETNAMES=YES;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SCANTEXT=YES;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; USEDATE=YES;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SCANTIME=YES;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DBSASLABEL=NONE;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TEXTSIZE=100;&lt;/P&gt;&lt;P&gt;&amp;nbsp; RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp; proc append data=_&amp;amp;i base=&amp;amp;out; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; proc delete data=_&amp;amp;i; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let rc=%sysfunc(dclose(&amp;amp;did));&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %mend MultImp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %MultImp(dir=C:\Users\Owner\Desktop\SAS Project\ACL CSV files,out=File);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Feb 2014 18:02:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184804#M35071</guid>
      <dc:creator>UT_Risom</dc:creator>
      <dc:date>2014-02-24T18:02:34Z</dc:date>
    </item>
    <item>
      <title>Re: Help merging multiple CSV files to a dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184805#M35072</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Perhaps if your CSVs are all the same you can read them using a file reference with wildcard.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;filename csv160 'path/BTLT4-*.csv';&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Feb 2014 18:32:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184805#M35072</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-02-24T18:32:29Z</dc:date>
    </item>
    <item>
      <title>Re: Help merging multiple CSV files to a dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184806#M35073</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you need those double quotes?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; %let rc=%sysfunc(filename(mydir,&lt;STRONG&gt;"&lt;/STRONG&gt;&amp;amp;dir&lt;STRONG&gt;"&lt;/STRONG&gt;));&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Feb 2014 18:34:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184806#M35073</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-02-24T18:34:23Z</dc:date>
    </item>
    <item>
      <title>Re: Help merging multiple CSV files to a dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184807#M35074</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you tried examining &amp;amp;DID to see whether you have the proper syntax for identifying the folder?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Right after creating it would be the right place to stick a %PUT statement.&amp;nbsp; Probably a value of 0 indicates the folder was not properly identified, but the documentation on DOPEN would confirm that.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Feb 2014 18:44:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184807#M35074</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-02-24T18:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: Help merging multiple CSV files to a dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184808#M35075</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;After including &lt;STRONG&gt;%put &amp;amp;did;&lt;/STRONG&gt; into my syntax, I was indeed given a value of 0. What can I do to fix this?&lt;/P&gt;&lt;P&gt;- SMR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As a reminder, this is the error I receive for the syntax above&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;WARNING: Argument 1 to function DNUM referenced by the %SYSFUNC or %QSYSFUNC macro function is out&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; of range.&lt;/P&gt;&lt;P&gt;NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result of the operations have been set to a missing value.&lt;/P&gt;&lt;P&gt;0&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 00:52:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184808#M35075</guid>
      <dc:creator>UT_Risom</dc:creator>
      <dc:date>2014-02-25T00:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: Help merging multiple CSV files to a dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184809#M35076</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To figure that out, I would have to read the documentation on DOPEN, and fiddle with it till I found what DOPEN expects.&amp;nbsp; I would submit that you should do that part.&amp;nbsp; Instead of MYDIR, figure out what DOPEN expects in this statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let did = %sysfunc(dopen(mydir));&lt;/P&gt;&lt;P&gt;%put DID is &amp;amp;did&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once you find a value of &amp;amp;DID that is nonzero, the rest will be much easier.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You won't need a full-blown macro.&amp;nbsp; Playing with just those two lines of code would be enough.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 02:29:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184809#M35076</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-02-25T02:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: Help merging multiple CSV files to a dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184810#M35077</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;PROC IMPORT is NOT what you want to use if you have 160 files all with same 167 variables.&lt;/P&gt;&lt;P&gt;You might use it once and recall the code it generates to help you construct the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want ;&lt;/P&gt;&lt;P&gt;* Define the 167 variables - You can use real names I will use var1-var167 as an example ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; length var1 var2 ..... var167 ;&lt;/P&gt;&lt;P&gt;* Add some INFORMAT and FORMAT statement for variables that need them, i.e. DATEs and TIMEs ;&lt;/P&gt;&lt;P&gt;* You do NOT want to attach either INFORMATS or FORMATS to simple strings and numbers;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; infile "&amp;amp;mydir/&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;BTLT4-&lt;/SPAN&gt;*.csv"&amp;nbsp; dsd truncover lrecl=32000 ;&lt;/P&gt;&lt;P&gt;* Throw away the header lines;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input @; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if upcase(_infile_)=:'VAR1,' then delete;&lt;/P&gt;&lt;P&gt;* Read the data ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input var1 --- var167 ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 04:29:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184810#M35077</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-02-25T04:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: Help merging multiple CSV files to a dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184811#M35078</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you try to open every file (of an unknown number of files) by itself, you may run out of available file handles (limit depending on the operating system).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In cases like this, I prefer to concatenate all the files with the help of the OS so I only have to read one file in SAS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(eg UNIX "cat xxxx* &amp;gt; xxxx.concat").&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But then, I have the blessing of running SAS on a Unix instead of Windows.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 08:12:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184811#M35078</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2014-02-25T08:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: Help merging multiple CSV files to a dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184812#M35079</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think it would be better to use the INFILE statement option EOV= that is intended for the purpose of detecteing when a new file has been opened than to use rely the value of a data line.&amp;nbsp; The OP might also like to know the name of each file provided by the FILENAME= option.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 11:36:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184812#M35079</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-02-25T11:36:22Z</dc:date>
    </item>
    <item>
      <title>Re: Help merging multiple CSV files to a dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184813#M35080</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Seonding Kurts answer here.&amp;nbsp; If they are all the same type of file then "copy *.csv all_csv.csv" in CMD is probably easiest.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 15:13:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184813#M35080</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-02-25T15:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: Help merging multiple CSV files to a dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184814#M35081</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think that is a good idea at all.&amp;nbsp; SAS will not open all the files and once and if we do as you suggest we won't be able to tell when a new file is opened EOV= or know the name of the file FILENAME=.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 16:05:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184814#M35081</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-02-25T16:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: Help merging multiple CSV files to a dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184815#M35082</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure I follow you.&amp;nbsp; I am suggesting appending the text CSV files outside of SAS into one big file.&amp;nbsp; Then in SAS importing that one file to create the final dataset.&amp;nbsp; This as an alternative to importing into SAS many files, then appending them.&amp;nbsp; If you need to do it several times, save the dos commands in a batch file.&amp;nbsp; Then each time, copy over all your .CSV files.&amp;nbsp; Run the batch file to create one big .CSV, and then run your SAS program to import that one complete file.&amp;nbsp; The SAS code is a very simple proc import then.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 16:20:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184815#M35082</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-02-25T16:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: Help merging multiple CSV files to a dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184816#M35083</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What about the header lines in each CSV file?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 16:32:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184816#M35083</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-02-25T16:32:02Z</dc:date>
    </item>
    <item>
      <title>Re: Help merging multiple CSV files to a dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184817#M35084</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote" modifiedtitle="true"&gt;
&lt;P&gt;RW9 wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Not sure I follow you.&amp;nbsp; I am suggesting appending the text CSV files outside of SAS into one big file.&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And I am suggesting that you NOT do that because SAS has better tools to deal with reading concatenate files.&amp;nbsp; Look at my first reply where I suggest reading the files using a wildcard then there is a reply from Tom where he supplies a more complete example.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 16:52:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184817#M35084</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-02-25T16:52:24Z</dc:date>
    </item>
    <item>
      <title>Re: Help merging multiple CSV files to a dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184818#M35085</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;After replacing the PROC IMPORT statement to the syntax below I'm still getting the following error. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dir=C:\Users\Owner\Desktop\SAS Project\ACL CSV files\&lt;/P&gt;&lt;P&gt;did=0&lt;/P&gt;&lt;P&gt;WARNING: Argument 1 to function DNUM referenced by the %SYSFUNC or %QSYSFUNC macro function is out &lt;SPAN style="font-size: 10pt;"&gt;of range.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;NOTE: Mathematical operations could not be performed during %SYSF&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;BTW, thanks for your help thus far! As a beginner with SAS macro all help is appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- SMR &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;options mprint;&lt;/P&gt;&lt;P&gt; %macro MultImp(dir=,out=);&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let rc=%sysfunc(filename(mydir,&amp;amp;dir));&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let did=%sysfunc(dopen(mydir));&lt;/P&gt;&lt;P&gt;%put dir=&amp;amp;dir;&lt;/P&gt;&lt;P&gt;%put did=&amp;amp;did;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let filrf=MYDIR;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let lstname=;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let memcount=%sysfunc(dnum(&amp;amp;did));&lt;/P&gt;&lt;P&gt;&amp;nbsp; %if &amp;amp;memcount &amp;gt; 0 %then %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %do i=1 %to &amp;amp;memcount;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let lstname=%sysfunc(dread(&amp;amp;did,&amp;amp;i));&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let file=&amp;amp;dir.&amp;amp;lstname;&lt;/P&gt;&lt;P&gt;&amp;nbsp; data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; length var1 var2 ..... var167 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; infile "&amp;amp;mydir\BTLT4-*.csv"&amp;nbsp; dsd truncover lrecl=32000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input @;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if upcase(_infile_)=:'VAR1,' then delete;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input var1 --- var167 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; proc append data=_&amp;amp;i base=&amp;amp;out; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; proc delete data=_&amp;amp;i; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let rc=%sysfunc(dclose(&amp;amp;did));&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %mend MultImp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %MultImp(dir=C:\Users\Owner\Desktop\SAS Project\ACL CSV files\,out=File);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 17:38:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184818#M35085</guid>
      <dc:creator>UT_Risom</dc:creator>
      <dc:date>2014-02-25T17:38:10Z</dc:date>
    </item>
    <item>
      <title>Re: Help merging multiple CSV files to a dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184819#M35086</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="468858" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; proposed a simple alternative to your macro&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data want( compress= yes);&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; length var1 var2 ..... var167 $20 filen filename $100;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; infile "&amp;amp;mydir\BTLT4-*.csv"&amp;nbsp; dsd truncover lrecl=32000 eov=eov filename= filen firstobs=2;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp; input @;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; filename= filen ;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; if eov then delete;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; input var1 --- var167 ;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;of course I'm not &lt;A __default_attr="468858" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; so I have probably got it "not quite right", but this is the size of the solution (subject to proper definition of 167 lengths and/or informats)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 17:46:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184819#M35086</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2014-02-25T17:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: Help merging multiple CSV files to a dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184820#M35087</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would suggest ditching the complex macro code to get the list of filenames.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My preference in order would be&lt;/P&gt;&lt;P&gt;1) Just use a wildcard in the filename you reference in the INFILE statement so that SAS will find the files for you.&lt;/P&gt;&lt;P&gt;2) Use operating system command like ls or dir with a pipe to read the filenames.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data files; infile &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;"dir ""&amp;amp;mydir\BTLT4-*.csv"" /b" pipe truncover; input filename $256. ; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) If you really must use the functions like DOPEN then do it in an actual DATA step where you can put in some PUT statements or even use the SAS datastep debugger to see what is happening.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 17:49:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184820#M35087</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-02-25T17:49:23Z</dc:date>
    </item>
    <item>
      <title>Re: Help merging multiple CSV files to a dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184821#M35088</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was able to create a macros to compile the list of files in my directory, just to see if that was the issue. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*compiled directory*/&lt;/P&gt;&lt;P&gt;%macro get_filenames(location);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; filename pipedir pipe "dir ""%unquote(&amp;amp;location)"" /b"; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; data files;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile pipedir truncover;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input filename $256.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; put filename=;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; filename pipedir clear;&amp;nbsp; &lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%get_filenames(C:\Users\Owner\Desktop\SAS Project\ACL CSV files)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately I'm still running into the same issue with the previous syntax, even after adjusting the infile statement. Are there any examples of alternative syntax (with or without macros) you recommend looking at, or if your willing to show me how to arrange what I have in a way that might be more efficient?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- SMR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*adjusted syntax*/&lt;/P&gt;&lt;P&gt;options mprint;&lt;/P&gt;&lt;P&gt;%macro MultImp(dir=,out=);&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let rc=%sysfunc(filename(mydir,&amp;amp;dir));&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let did=%sysfunc(dopen(mydir));&lt;/P&gt;&lt;P&gt;%put dir=&amp;amp;dir;&lt;/P&gt;&lt;P&gt;%put did=&amp;amp;did;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let filrf=MYDIR;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let lstname=;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let memcount=%sysfunc(dnum(&amp;amp;did));&lt;/P&gt;&lt;P&gt;&amp;nbsp; %if &amp;amp;memcount &amp;gt; 0 %then %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %do i=1 %to &amp;amp;memcount;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let lstname=%sysfunc(dread(&amp;amp;did,&amp;amp;i));&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let file=&amp;amp;dir.&amp;amp;lstname;&lt;/P&gt;&lt;P&gt;data files;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile "dir ""&amp;amp;mydir\BTLT4-*.csv"" /b" pipe truncover; &lt;/P&gt;&lt;P&gt;&amp;nbsp; input filename $256.; &lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; proc append data=_&amp;amp;i base=&amp;amp;out; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; proc delete data=_&amp;amp;i; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let rc=%sysfunc(dclose(&amp;amp;did));&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %mend MultImp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %MultImp(dir=C:\Users\Owner\Desktop\SAS Project\ACL CSV files\,out=File);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 23:05:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184821#M35088</guid>
      <dc:creator>UT_Risom</dc:creator>
      <dc:date>2014-02-25T23:05:51Z</dc:date>
    </item>
    <item>
      <title>Re: Help merging multiple CSV files to a dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184822#M35089</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data files;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile "dir ""&amp;amp;mydir\BTLT4-*.csv"" /b" pipe truncover; &lt;/P&gt;&lt;P&gt;&amp;nbsp; input filename $256.; &lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; proc append data=_&amp;amp;i base=&amp;amp;out; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; proc delete data=_&amp;amp;i; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This part doesn't look correct.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Should it be data &amp;amp;out or _&amp;amp;i or something else. Using a Static name with the wild card doesn't make sense after you've inputted all the file names as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use the solution posted by Data _null_ above. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 23:12:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184822#M35089</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-02-25T23:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: Help merging multiple CSV files to a dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184823#M35090</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tried the &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;solution posted by Data _null_ above.&lt;/SPAN&gt; Still the same issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- SMR&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 23:31:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/m-p/184823#M35090</guid>
      <dc:creator>UT_Risom</dc:creator>
      <dc:date>2014-02-25T23:31:11Z</dc:date>
    </item>
  </channel>
</rss>

