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
Specified Folder
In-Reply-To: <201111152103.pAFK2GVS024640@waikiki.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"
Hi Mary:
http://www.sascommunity.org/wiki/Making_Lists#Make_List_of_Files
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: owner-sas-l@listserv.uga.edu [mailto:owner-sas-l@listserv.uga.edu]
> 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
> Folder
>
> 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
> $char200.;
>
> progline = upcase(left(progline));
> run;
>
> 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.
>
> Cheers,
> Mary R.
|