|Date: ||Tue, 24 Apr 2007 14:14:32 -0700|
|Reply-To: ||David L Cassell <davidlcassell@MSN.COM>|
|Sender: ||"SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>|
|From: ||David L Cassell <davidlcassell@MSN.COM>|
|Subject: ||Re: About macros, X and Unix|
|Content-Type: ||text/plain; format=flowed|
> I'm using SAS 9.1 in batch mode under Unix.
> I'm used to make the file manipulation inside the UNIX shell and then
>make my SAS programs.
> But now I want to know if something like this may work:
> %macro newdata(month=)
> Libname one ‘$HOME/&month’;
> X “mkdir $HOME/&month/DIRECTORY1”;
> X “cp $HOME/&month/file1.Z $HOME/&month/DIRECTORY1”;
> and then the normal code to import the files to SAS…
> I tried something like this but didn’t work.
> Is any way to combine macros with X to get all in only one automatic
>Guido (From Argentina).
As others have pointed out, there are some basic problems with your
But I would like to step even farther back in the process. SAS is not
Excel or Word. You do not need to store every month's worth of data
in a separate directory. That will just make your life harder, later on
when you have to work with the files.
If a couple hours of prep work will save you weeks of agony later on,
then do the prep work. This is what Larry Wall calls 'laziness'. :-)
So maintain your SAS data in a single tall-and-thin database that has
all the monthly data inside it. Then use WHERE clauses or by-processing
or whatever SAS can provide for you, so that you do not have to
painfully find the right directories and re-build the right components
every single time.
If you do this, then your above process is not needed, so your macro
programming problem goes away too.
Then, before you start this type of process again, look up the SAS
tools for doing things like creating directories internally, instead of
out to a child process to muck about with the files and dirs. You
might start with the DCREATE() function.
David L. Cassell
3115 NW Norwood Pl.
Corvallis OR 97330
Exercise your brain! Try Flexicon.