Date: Tue, 11 Mar 2008 12:01:28 -0700
Reply-To: Bill McKirgan <Bill.McKirgan@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Bill McKirgan <Bill.McKirgan@GMAIL.COM>
Subject: Re: Automate running SAS code and creation of folders/directories
at regular interval
Content-Type: text/plain; charset=ISO-8859-1
On Mar 11, 12:27 pm, Minion <acfar...@gmail.com> wrote:
> On Mar 11, 10:42 am, Bill McKirgan <Bill.McKir...@gmail.com> wrote:
> > On Mar 11, 8:38 am, vicks <vikaslbish...@gmail.com> wrote:
> > > Thanks Bill.
> > > I was able to create the directory structure.
> > > Now, the problem I am facing is copying the sas files from the earlier
> > > directory to the current (new) directory.
> > > I am not quite familiar with the x term commands.
> > > Although I did try this:
> > > DATA _null_;
> > > week_date=today()-1;
> > > old_week_date=today()-8;
> > > call symput('oldstamp',put(old_week_date,yymmddN8.));
> > > call symput('datestamp',put(week_date,yymmddN8.));
> > > RUN;
> > > /* options noxwait; */
> > > x mkdir "&DATESTAMP";
> > > x mkdir "&DATESTAMP./code";
> > > x mkdir "&DATESTAMP./data";
> > > x cp "/home/user/&OLDSTAMP./code/program1.sas /home/user/&DATESTAMP./
> > > code/program1.sas";
> > > cp "/home/user/&OLDSTAMP./code/program2.sas /home/user/&DATESTAMP./
> > > code/program2.sas";
> > > In the above code
> > > - noxwait shows as an unrecognized option!
> > > - and the copying of sas programs using the x terminal cp command does
> > > not work!!!
> > > Thanks again for all your help.
> > Sure, glad to help.
> > The 'noxwait' is commented-out, but should be ignored by SAS. If
> > there is an error message can you show the log for that?
> > As for using the copy command 'cp' with x terminal I would say your
> > code looks like it should work. Perhaps if you quote the source and
> > destination paths individually... cp "source" "destination" ;
> > Unfortunately this is an area where I rely on trial and error, and
> > working in a safe area where I can do no harm to the real data.
> In some situations, users may find x commands disabled as part of a
> system policy to prevent user created sub-processes. This is the
> default for Enterprise Guide and most SASv9 clients connecting to
> You might want to consider looking at dcreate or, on Unix, wrapping
> your weekly process in a shell script that can be scheduled. In ksh,
> this kind of function might be helpful:
> ### Create sub-directory as YYYYMMDD, using current date, if it does
> not exist.
> yyyymmdd=`date '+%Y%m%d'`
> if [[ -d $yyyymmdd ]]; then
> echo "`date '+%H:%M:%S'` - Directory $yyyymmdd exists"
> mkdir $yyyymmdd
> echo "`date '+%H:%M:%S'` - Directory $yyyymmdd created"
> fi- Hide quoted text -
> - Show quoted text -
That's got to be the best approach especially if permissions become an
issue. Nice work outlining the process M.
Now, I'm playing around with it on a bash shell using 'cygwin' on XP.
The datestamp variable I get is a 2-digit year.
If I change the 'y' to 'Y',
It then has a 4digit year