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
On Thu, 13 Sep 2001 07:29:21 -0700, Sharon Ryan <sharon@MATLOCK.WUSTL.EDU>
>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
>foreach i (*.ssd01)
>cp $i $i.20010913
>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))";
length file $50 date $8;
if not did then stop;
do i = 1 to dnum(did);
if np then do;
rc=system('rename '||trim(file)||' '||substr(file,1,np)