Date: Tue, 15 Nov 2011 16:34:51 -0500
Reply-To: "Bian, Haikuo" <HBian@FLQIO.SDPS.ORG>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Bian, Haikuo" <HBian@FLQIO.SDPS.ORG>
Subject: Re: Create a SAS Dataset Containing Names of .csv Files in a
Content-Type: text/plain; charset="us-ascii"
The simplest way that I can think of is to invoke 'x' command. Here is one approach you could try:
x 'dir *.csv c:\ /b /d >c:\csv.txt';
filename csv "c:\csv.txt";
input file_name $200.;
please replace 'c:\' with your own folder name.
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Mary Rosenbloom
Sent: Tuesday, November 15, 2011 4:03 PM
Subject: Create a SAS Dataset Containing Names of .csv Files in a Specified Folder
I have a folder with several .csv files. I want to create a dataset
containing one record per .csv file, with a variable that contains the
filename of the .csv file. So for example, if D:\projects contains
data1.csv, data2.csv, data3.csv then I have a dataset with 3 observations,
containing one variable which has the values data1, data2, data3 (also
acceptable would be data1.csv, data2.csv, data3.csv). I have previously
been able to use similar code to tell me the names of subfolders, but now
I want the names of CSV files. Here is what I have tried:
infile "C:\Projects\*csv" lrecl = 200 pad;
length progline $200;
input progline $char200.;
progline = upcase(left(progline));
I would appreciate code help as well as any references that you may have.
I recently purchased Burlew's "Reading External Data Files Using SAS", but
feel like I have a mountain to climb in terms of understanding this
Thanks for your assistance.
Email messages cannot be guaranteed to be secure or error-free as
transmitted information can be intercepted, corrupted, lost,
destroyed, arrive late or incomplete, or contain viruses. The
Centers for Medicare & Medicaid Services therefore does not accept
liability for any error or omissions in the contents of this
message, which arise as a result of email transmission.
CONFIDENTIALITY NOTICE: This communication, including any
attachments, may contain confidential information and is intended
only for the individual or entity to which it is addressed. Any
review, dissemination, or copying of this communication by anyone
other than the intended recipient is strictly prohibited. If you
are not the intended recipient, please contact the sender by reply
email and delete and destroy all copies of the original message.