<?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: convert large number of text files into SAS all at once in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51529#M10838</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; font-size: 10pt;"&gt;Hi,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; font-size: 10pt;"&gt;If you want to try my code, first save the text below to c:\temp as &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; font-size: 10pt;"&gt;20120101_testdate.txt&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; font-size: 10pt;"&gt;20120201_testdate.txt&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; font-size: 10pt;"&gt;20120301_testdate.txt&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Region~State~Month~Expenses~Revenue&lt;/P&gt;&lt;P&gt;Southern~GA~JAN97~2000~8000&lt;/P&gt;&lt;P&gt;Southern~GA~FEB97~1200~6000&lt;/P&gt;&lt;P&gt;Southern~FL~FEB97~8500~11000&lt;/P&gt;&lt;P&gt;Northern~NY~FEB97~3000~4000&lt;/P&gt;&lt;P&gt;Northern~NY~MAR97~6000~5000&lt;/P&gt;&lt;P&gt;Southern~FL~MAR97~9800~13500&lt;/P&gt;&lt;P&gt;Northern~MA~MAR97~1500~1000&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; font-size: 10pt;"&gt;/*After run my code, you should have 3 datasets &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; font-size: 10pt;"&gt;_20120101_testdate.sas7bdat,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; font-size: 10pt;"&gt;_20120201_testdate.sas7bdat,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; font-size: 10pt;"&gt;_20120301_testdate.sas7bdat&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; font-size: 10pt;"&gt;Created in your work library.*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%macro test(location);/* location is where the files are stored */ &lt;/P&gt;&lt;P&gt;filename indata pipe "dir &amp;amp;location.\*.txt /b"; /*find the files*/&lt;/P&gt;&lt;P&gt;data files;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length in_name out_name $32;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile indata truncover;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input in_name $32.; /* input the file names */&lt;/P&gt;&lt;P&gt;&amp;nbsp; out_name=cats('_',scan(in_name,1,'.'));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;options mprint mlogic;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set files end=last;&lt;/P&gt;&lt;P&gt;&amp;nbsp; call symputx(cats('dsn',strip(_n_)),in_name);&lt;/P&gt;&lt;P&gt;&amp;nbsp; call symputx(cats('outdsn',strip(_n_)),out_name);&lt;/P&gt;&lt;P&gt;&amp;nbsp; if last then call symputx('n',_n_);&lt;/P&gt;&lt;P&gt; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %do i=1 %to &amp;amp;n;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc import datafile="&amp;amp;location.\&amp;amp;&amp;amp;dsn&amp;amp;i." out= work.&amp;amp;&amp;amp;outdsn&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; dbms=dlm replace ;&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; delimiter="~";&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; getnames=yes;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%test(c:\temp)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; font-size: 10pt;"&gt;Linlin &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 06 Apr 2012 19:38:13 GMT</pubDate>
    <dc:creator>Linlin</dc:creator>
    <dc:date>2012-04-06T19:38:13Z</dc:date>
    <item>
      <title>convert large number of text files into SAS all at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51521#M10830</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;I just learned SAS programming language by reading a book this month.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have to convert a few hundred tilde delimited text files into SAS format.&amp;nbsp; Is there a way to do that?&lt;/P&gt;&lt;P&gt;For now, I am converting them using PROC IMPORT one at the time...there must have been a more efficient way to do that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your answers &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cyndia&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Mar 2012 23:05:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51521#M10830</guid>
      <dc:creator>Cyndia</dc:creator>
      <dc:date>2012-03-30T23:05:39Z</dc:date>
    </item>
    <item>
      <title>convert large number of text files into SAS all at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51522#M10831</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;there is no need to merge or combine any files.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Mar 2012 23:11:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51522#M10831</guid>
      <dc:creator>Cyndia</dc:creator>
      <dc:date>2012-03-30T23:11:10Z</dc:date>
    </item>
    <item>
      <title>convert large number of text files into SAS all at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51523#M10832</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=2&amp;amp;ved=0CC0QFjAB&amp;amp;url=http%3A%2F%2Fwww2.sas.com%2Fproceedings%2Fsugi29%2F057-29.pdf&amp;amp;ei=GkB2T-r6N8GL0QGLkOi9DQ&amp;amp;usg=AFQjCNGnm_E85BCzISj25fTMBJlvguvGhg"&gt;http://www2.sas.com/proceedings/sugi29/057-29.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found a paper for your requirement. Hoping this is what you are looking for.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Mar 2012 23:24:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51523#M10832</guid>
      <dc:creator>Hima</dc:creator>
      <dc:date>2012-03-30T23:24:47Z</dc:date>
    </item>
    <item>
      <title>convert large number of text files into SAS all at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51524#M10833</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Hima.&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&amp;nbsp; I am going to try it and let you know.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Mar 2012 23:29:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51524#M10833</guid>
      <dc:creator>Cyndia</dc:creator>
      <dc:date>2012-03-30T23:29:39Z</dc:date>
    </item>
    <item>
      <title>convert large number of text files into SAS all at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51525#M10834</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Depending upon the kind of computer you are on, where the files are located, how the files are called, whether they all contain a first line of variable names, and where you want the new SAS files placed, the following might help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are on Windows, all of your files have a .txt extension and are all located in the same directory, all contain a first line of variable labels, and you want them all converted to SAS files in a certain directory, you could use something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let file_location=c:\art\test\; /*where files are located*/&lt;/P&gt;&lt;P&gt;filename indata pipe "dir &amp;amp;file_location.*.txt /b"; /*find the files*/&lt;/P&gt;&lt;P&gt;libname mydata "c:\art\mydata"; /*where to put the SAS datasets*/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data data_null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length fname $32;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length fname_wo_ext $29;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile indata truncover;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input fname $20.; /* input the file names */&lt;/P&gt;&lt;P&gt;&amp;nbsp; fname_wo_ext=substr(fname,1,length(fname)-4);&lt;/P&gt;&lt;P&gt;&amp;nbsp; call execute(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; "Proc import out=mydata." || strip(fname_wo_ext)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; || " dataFile="||"'&amp;amp;file_location."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ||fname||"' dbms=dlm REPLACE ;"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ||'delimiter="~";GETNAMES=YES ; RUN ;'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ) ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 Mar 2012 01:52:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51525#M10834</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-03-31T01:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: convert large number of text files into SAS all at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51526#M10835</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i got the following error message:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4&amp;nbsp; !+&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' dbms=dlm REPLACE ;delimiter=",";GETNAMES=YES ; RUN ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: ;, (, DATAFILE, DATATABLE, DBMS,&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; DEBUG, FILE, OUT, REPLACE, TABLE, _DEBUG_.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR 202-322: The option or parameter is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since the original text file names all begin with numbers, e.g. 20120101_testdata.txt, how to prefix an '_' to all the converted&amp;nbsp; *.sas files?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;||'_' somewhere to the beginning of the new *.sas file names?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Apr 2012 18:40:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51526#M10835</guid>
      <dc:creator>Cyndia</dc:creator>
      <dc:date>2012-04-02T18:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: convert large number of text files into SAS all at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51527#M10836</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Any ideas?&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Apr 2012 16:36:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51527#M10836</guid>
      <dc:creator>Cyndia</dc:creator>
      <dc:date>2012-04-06T16:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: convert large number of text files into SAS all at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51528#M10837</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I made this code work on some sample files. I'm sure someone who does this kind of work all the time could refine/simplify the code...but it did work for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I got started from this link:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www2.sas.com/proceedings/sugi29/057-29.pdf"&gt;http://www2.sas.com/proceedings/sugi29/057-29.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;and using the answer @art297 provided&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Options symbolgen mlogic mprint ;&lt;BR /&gt;%macro Get_Files;&lt;BR /&gt;&amp;nbsp; %Let folder=d:\data\test;&lt;BR /&gt;&amp;nbsp; filename indata pipe "dir &amp;amp;folder. /b";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* Get the filenames from the pipe directory command */&lt;/P&gt;&lt;P&gt;&amp;nbsp; data file_list;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; length fname $50;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; infile indata truncover; /* infile statement for file names */&lt;BR /&gt;&amp;nbsp;&amp;nbsp; input fname $50.;&amp;nbsp; /* read the file names from the directory */&lt;BR /&gt;&amp;nbsp;&amp;nbsp; dsn_name=scan(fname,1,"."); /*Assuming there is an extension on filename (ex .txt)*/&lt;BR /&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* Get filenames into macro variables */&lt;BR /&gt;&amp;nbsp; Proc Sql noprint;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; select count(fname)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; into :cnt&lt;BR /&gt;&amp;nbsp;&amp;nbsp; from work.file_list;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %Let cnt=&amp;amp;cnt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; select fname, dsn_name&lt;BR /&gt;&amp;nbsp;&amp;nbsp; into :fname1 - :fname&amp;amp;cnt, :dsn1 - :dsn&amp;amp;cnt&lt;BR /&gt;&amp;nbsp;&amp;nbsp; from work.file_list;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Loop through all file names to import */&lt;BR /&gt;%Do i = 1 %to &amp;amp;cnt;&lt;BR /&gt;%Let file_name=&amp;amp;&amp;amp;fname&amp;amp;i;&lt;BR /&gt;%Let dsn_name=&amp;amp;&amp;amp;dsn&amp;amp;i;&lt;/P&gt;&lt;P&gt;Proc import out=work._&amp;amp;dsn_name&lt;BR /&gt;&amp;nbsp;&amp;nbsp; dataFile="&amp;amp;folder.\&amp;amp;file_name" dbms=dlm REPLACE ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; delimiter="~";&lt;BR /&gt;&amp;nbsp;&amp;nbsp; GETNAMES=YES ; &lt;BR /&gt;&amp;nbsp; RUN ;&lt;BR /&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%Mend get_files;&lt;/P&gt;&lt;P&gt;%get_Files&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Jay Corbett&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Apr 2012 17:47:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51528#M10837</guid>
      <dc:creator>Jay_TxOAG</dc:creator>
      <dc:date>2012-04-06T17:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: convert large number of text files into SAS all at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51529#M10838</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; font-size: 10pt;"&gt;Hi,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; font-size: 10pt;"&gt;If you want to try my code, first save the text below to c:\temp as &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; font-size: 10pt;"&gt;20120101_testdate.txt&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; font-size: 10pt;"&gt;20120201_testdate.txt&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; font-size: 10pt;"&gt;20120301_testdate.txt&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Region~State~Month~Expenses~Revenue&lt;/P&gt;&lt;P&gt;Southern~GA~JAN97~2000~8000&lt;/P&gt;&lt;P&gt;Southern~GA~FEB97~1200~6000&lt;/P&gt;&lt;P&gt;Southern~FL~FEB97~8500~11000&lt;/P&gt;&lt;P&gt;Northern~NY~FEB97~3000~4000&lt;/P&gt;&lt;P&gt;Northern~NY~MAR97~6000~5000&lt;/P&gt;&lt;P&gt;Southern~FL~MAR97~9800~13500&lt;/P&gt;&lt;P&gt;Northern~MA~MAR97~1500~1000&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; font-size: 10pt;"&gt;/*After run my code, you should have 3 datasets &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; font-size: 10pt;"&gt;_20120101_testdate.sas7bdat,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; font-size: 10pt;"&gt;_20120201_testdate.sas7bdat,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; font-size: 10pt;"&gt;_20120301_testdate.sas7bdat&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; font-size: 10pt;"&gt;Created in your work library.*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%macro test(location);/* location is where the files are stored */ &lt;/P&gt;&lt;P&gt;filename indata pipe "dir &amp;amp;location.\*.txt /b"; /*find the files*/&lt;/P&gt;&lt;P&gt;data files;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length in_name out_name $32;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile indata truncover;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input in_name $32.; /* input the file names */&lt;/P&gt;&lt;P&gt;&amp;nbsp; out_name=cats('_',scan(in_name,1,'.'));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;options mprint mlogic;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set files end=last;&lt;/P&gt;&lt;P&gt;&amp;nbsp; call symputx(cats('dsn',strip(_n_)),in_name);&lt;/P&gt;&lt;P&gt;&amp;nbsp; call symputx(cats('outdsn',strip(_n_)),out_name);&lt;/P&gt;&lt;P&gt;&amp;nbsp; if last then call symputx('n',_n_);&lt;/P&gt;&lt;P&gt; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %do i=1 %to &amp;amp;n;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc import datafile="&amp;amp;location.\&amp;amp;&amp;amp;dsn&amp;amp;i." out= work.&amp;amp;&amp;amp;outdsn&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; dbms=dlm replace ;&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; delimiter="~";&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; getnames=yes;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%test(c:\temp)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; font-size: 10pt;"&gt;Linlin &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Apr 2012 19:38:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51529#M10838</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-04-06T19:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: convert large number of text files into SAS all at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51530#M10839</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use the cats function to add a prefix.&amp;nbsp; e.g.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let file_location=c:\art\test\; /*where files are located*/&lt;/P&gt;&lt;P&gt;filename indata pipe "dir &amp;amp;file_location.*.txt /b"; /*find the files*/&lt;/P&gt;&lt;P&gt;libname mydata "c:\art\mydata"; /*where to put the SAS datasets*/&lt;/P&gt;&lt;P&gt;data data_null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length fname $32;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length fname_wo_ext $29;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile indata truncover;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input fname $32.; /* input the file names */&lt;/P&gt;&lt;P&gt;&amp;nbsp; fname_wo_ext=cats('_',substr(fname,1,length(fname)-4));&lt;/P&gt;&lt;P&gt;&amp;nbsp; call execute(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; "Proc import out=mydata." || strip(fname_wo_ext)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; || " dataFile="||"'&amp;amp;file_location."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ||fname||"' dbms=dlm REPLACE ;"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ||'delimiter="~";GETNAMES=YES ; RUN ;'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ) ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Apr 2012 20:04:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51530#M10839</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-04-06T20:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: convert large number of text files into SAS all at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51531#M10840</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i will try this, too.&amp;nbsp; thanks to linlin :smileycool:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Apr 2012 20:19:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51531#M10840</guid>
      <dc:creator>Cyndia</dc:creator>
      <dc:date>2012-04-06T20:19:24Z</dc:date>
    </item>
    <item>
      <title>Re: convert large number of text files into SAS all at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51532#M10841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;lemme try them and let you know.&amp;nbsp; thx again, art297.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i haven't read about SAS macros yet.:smileymischief:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Apr 2012 20:21:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51532#M10841</guid>
      <dc:creator>Cyndia</dc:creator>
      <dc:date>2012-04-06T20:21:22Z</dc:date>
    </item>
    <item>
      <title>Re: convert large number of text files into SAS all at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51533#M10842</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks, Jay. &lt;/P&gt;&lt;P&gt;i read the pdf doc "A Macro for Reading Multiple Text Files" and was able to get the list of the files, but had trouble getting the rest of the code to work.&amp;nbsp; will try it.&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Apr 2012 20:26:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51533#M10842</guid>
      <dc:creator>Cyndia</dc:creator>
      <dc:date>2012-04-06T20:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: convert large number of text files into SAS all at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51534#M10843</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;%let file_location=c:\temp\; /*where files are located*/&lt;/P&gt;&lt;P&gt;filename indata pipe "dir &amp;amp;file_location.*.txt /b"; /*find the files*/&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length fname fname_wo_ext $32;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile indata truncover;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input fname $32.; /* input the file names */&lt;/P&gt;&lt;P&gt;&amp;nbsp; fname_wo_ext=cats('_',scan(fname,1,'.'));&lt;/P&gt;&lt;P&gt;&amp;nbsp; call execute(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "proc import out= work."||fname_wo_ext&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; ||" datafile= "||"'&amp;amp;file_location."||fname||"'&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; dbms=dlm replace ;&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; delimiter='~';&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; getnames=yes;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;");&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Linlin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Apr 2012 11:52:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51534#M10843</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-04-07T11:52:25Z</dc:date>
    </item>
    <item>
      <title>Re: convert large number of text files into SAS all at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51535#M10844</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The solutions you provided turned out to be great.&amp;nbsp; They work seamlessly for the text files without extra spaces.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How did you learn SAS macro?&amp;nbsp; I am going to learn macro next.&amp;nbsp; Any book(s) you would recommend?&amp;nbsp; Big thanks for all &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://communities.sas.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Apr 2012 15:42:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51535#M10844</guid>
      <dc:creator>Cyndia</dc:creator>
      <dc:date>2012-04-11T15:42:45Z</dc:date>
    </item>
    <item>
      <title>Re: convert large number of text files into SAS all at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51536#M10845</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was lucky enough to attend SAS Macro I and II classes to get a good foundation....but the best advice I received about using macros is: Write it first without macros...just duplicate your code as much as is necessary to get it to work....then go back and put in the macro code a little at a time. Honestly, you can learn a lot from SAS's site and using Google...stay with it. Good luck&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Apr 2012 15:51:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51536#M10845</guid>
      <dc:creator>Jay_TxOAG</dc:creator>
      <dc:date>2012-04-11T15:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: convert large number of text files into SAS all at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51537#M10846</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are the fields the same or similar for all files?&lt;/P&gt;&lt;P&gt;Do you know the field names and data types?&lt;/P&gt;&lt;P&gt;Do you want a single data set in the end. (assuming common fields)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This paper &lt;A href="http://www.lexjansen.com/pharmasug/2011/tt/pharmasug-2011-tt04.pdf"&gt;http://www.lexjansen.com/pharmasug/2011/tt/pharmasug-2011-tt04.pdf&lt;/A&gt; includes an example program to read any number of files with common fields.&amp;nbsp; The fields don't have to exist in all files nor be in any particular column but you do have to to know the field names you want to read and define them as to type.&amp;nbsp; In other words you will need to know something about the data you are reading but there is no quessing as with PROC IMPORT.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Apr 2012 17:28:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-large-number-of-text-files-into-SAS-all-at-once/m-p/51537#M10846</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2012-04-11T17:28:04Z</dc:date>
    </item>
  </channel>
</rss>

