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 (January 1997, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 31 Jan 1997 11:37:47 +0500
Reply-To:   Bernard Tremblay <bernard@CAPITALE.QC.CA>
Sender:   "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:   Bernard Tremblay <bernard@CAPITALE.QC.CA>
Subject:   Re: getting date of file update/creation
Comments:   To: DavidPearson@FairIsaac.com
Comments:   cc: bernard@pollux.BITNET

Hi,

I knows not how to obtain the date from a SAS infile statement. But, you sure can use a pipe to read a UNIX "ls -l filename" result...

Here is an example I'm recycling from stuff used for something else:

%macro filedte(file); %*; filename dirlst pipe "ls -l &file" ; data _null_ ; infile dirlst length=ln end=eof; input line $varying200. ln; format access $10. owner $8. group $4. file $45. size 10. datec datetime. mon $3. day $2. yt $5.; access=scan(line,1,' '); owner=scan(line,3,' '); group=scan(line,4,' '); size=input(scan(line,5,' '),10.); mon=scan(line,6,' '); day=scan(line,7,' '); yt=scan(line,8,' '); if index(yt,':')>0 then datec=input(day||mon||trim(aaaa)||':'||yt,datetime16.); else datec=input(day||mon||trim(yt)||':00:00',datetime16.); file=scan(line,9,' ');

ext=trim(reverse(scan(reverse(file),1,'.')));

/* If all you need is a date, you may put it in a macro variable*/ call symput('fdate','"'||put(datec,datetime16.)||'"dt'); run; *; %mend;

/** then you only have to call the macro just before your datastep **/

%filedte(yourfile);

/* and now macro var &fdate contains the sas date of creation of your file in a datetime format */

... NB: The output of the command "ls -l filename" may differ from one version of UNIX to another, so you may have to modify the macro!

PS2: "La Capitale" is one of Fair,Isaac customers !

Hope it helps, Bernard Tremblay \\\|/// \\ - - // ( @ @ ) +------oOOo-(_)-oOOo----------+---------------------------------+ | Bernard Tremblay | | | La Capitale | Tel: (418) 646-2401 | | | Fax: (418) 646-5960 | | | Int: bernard@capitale.qc.ca | +-----------------------------+---------------------------------+ | Imaginasys enr | Res: (418) 878-4447 | | | Int: bertrem@quebectel.com | +---------------Oooo----------+---------------------------------+ oooO ( ) ( ) ) / \ ( (_/ \_)

>>>From owner-sas-l@UGA.CC.UGA.EDU Fri Jan 31 10:23 EST 1997 >>>X-Sender: "David B. Pearson" <DavidPearson@FairIsaac.com> (Unverified) >>>Mime-Version: 1.0 >>>X-Priority: Normal >>>Content-Transfer-Encoding: 7bit >>>Date: Fri, 31 Jan 1997 07:19:40 -0800 >>>From: "David B. Pearson" <DavidPearson@FairIsaac.com> >>>Subject: getting date of file update/creation >>>To: Multiple recipients of list SAS-L <SAS-L@UGA.CC.UGA.EDU> >>> >>>I'm trying to find a SAS function or option for the filename or infile >>>staments that would allow me to get the date that a particular file was >>>updated or created. I'm using SAS 6.09 TS042 on UNIX. I've checked the >>>Compainon for UNIX Environments: Language and the Compainon for UNIX >>>Environments & Derivatives. >>> >>>Anybody know of any options that will pick up the file date like the the >>>filename= option picks up the file's name in the infile statement? >>> >>>Thanks, >>>Dav


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