LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (April 2008, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 29 Apr 2008 07:05:02 -0700
Reply-To:     guya.carpenter@GMAIL.COM
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         guya.carpenter@GMAIL.COM
Organization: http://groups.google.com
Subject:      Re: Reading .TIF file names into SAS datasets
Comments: To: sas-l@uga.edu
Content-Type: text/plain; charset=ISO-8859-1

This was, admittedly, adapted from something somebody posted a few days ago, but I made it a little more adaptable.

Guy

%macro filnm(dir); %if %qsysfunc(substrn(%qsysfunc(reverse(&dir)),1,1)) ne \ %then %let dir=&dir.\;

/* Pipe files into text file. */

options noxwait;

x dir "&dir" > "&dir.&sysdate9..txt";

data _null_; wait=sleep(1); run;

/* Read file names into WORK.FILES ds. */

data files (drop=dirflg); length filetype $8; retain dir "&dir"; infile "&dir.&sysdate9..txt" recfm=v lrecl=256 truncover firstobs=6 end=eof; input @01 date anydtdte10. @12 time time5. @23 dirflg $3. @37 filename $100.; if lowcase(dirflg) ne 'dir'; if date ne .; if filename not in ('.','..',''); if filename ne "&sysdate9..txt"; format date date9. time time8.; filetype=upcase(scan(filename,-1,'.')); run;

proc sort data=files; by filetype filename date time; run;

x del "&dir.&sysdate9..txt";

/* Count and print files in dir. */

data _null_; set files nobs=nobs; call symput('num_files',left(nobs)); stop; run;

proc print data=files (drop=dir) noobs; run;

%put NOTE: Number of files in directory: &num_files; %put NOTE: Directory is: &dir;

%mend filnm;

%filnm (Y:\Ins & Fee Income\Analysis\Profiling\2008_02_15 affinion segmentation);


Back to: Top of message | Previous page | Main SAS-L page