Date: Tue, 15 Nov 2011 21:17:13 +0000
Reply-To: "Fehd, Ronald J. (CDC/OCOO/ITSO)" <rjf2@CDC.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Fehd, Ronald J. (CDC/OCOO/ITSO)" <rjf2@CDC.GOV>
Subject: Re: Create a SAS Dataset Containing Names of .csv Files in a
Content-Type: text/plain; charset="us-ascii"
you can add a subset:
if scan(FileName,-1,'.') eq 'csv' then output;
per your previous comments on these utilities:
* save both programs in same folder
* remember filename statement to allocate fileref SiteIncl
filename SiteIncl '.';*location of program: MlFiles.sas;
* open and submit MlFiles-caller.sas
Ron Fehd list maven
> -----Original Message-----
> From: email@example.com [mailto:firstname.lastname@example.org]
> On Behalf Of Mary Rosenbloom
> Sent: Tuesday, November 15, 2011 4:03 PM
> To: SAS-L@LISTSERV.UGA.EDU
> Cc: Mary Rosenbloom
> Subject: Create a SAS Dataset Containing Names of .csv Files in a Specified
> Hi all,
> 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:
> data pgms;
> infile "C:\Projects\*csv" lrecl = 200 pad; length progline $200; input progline
> 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 concept.
> Thanks for your assistance.
> Mary R.