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 (September 2001, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 13 Sep 2001 10:59:59 -0400
Reply-To:     "David L. Ward" <dward@SASHELP.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "David L. Ward" <dward@SASHELP.COM>
Subject:      Re: Unix or SAS help, please
Comments: To: Sharon Ryan <sharon@MATLOCK.WUSTL.EDU>

On Thu, 13 Sep 2001 07:29:21 -0700, Sharon Ryan <sharon@MATLOCK.WUSTL.EDU> wrote:

>I want to create backups for SAS files in a unix directory. The most >current file will always be "filename.ssd01" (yes, version6). I want >the backup file to be "filename.YYYYMMDD.ssd01" since that is the >existing naming convention. I can do them individually, but want to do >it over a series of files in a more effective way. > >The following Unix script works except that it gives me files of the >form "filename.ssd01.YYYYMMDD". Can anyone suggest a way to create >the series with the form I'm seeking? Since I'm new to Unix, I don't >know where to look. > >Thanks in advance. > ># make backups of data set files >#! /bin/csh >foreach i (*.ssd01) >cp $i $i.20010913 >end > > >P.S. If anyone can suggest a SAS solution, that would be great, too.

Here is a SAS solution. I could only test it on Windows and it worked fine.

libname data 'd:\test\sas'; filename dir "%sysfunc(pathname(data))"; options noxwait xsync; x "cd %sysfunc(pathname(data))"; data _null_; length file $50 date $8; did=dopen('dir'); if not did then stop; date=compress(year(date()))||put(month(date()),z2.)||put(day(date()),z2.); do i = 1 to dnum(did); file=dread(did,i); np=index(upcase(file),'.SSD01'); if np then do; rc=system('rename '||trim(file)||' '||substr(file,1,np) ||date||'.ssd01'); end; end; rc=dclose(did); run;

HTH David Ward SASHelp.com


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