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 (April 2007, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
In-Reply-To:   <973778.59315.qm@web90401.mail.mud.yahoo.com>
Content-Type:   text/plain; format=flowed

guidosagasti@YAHOO.COM.AR wrote: >Hello, > 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… > %mend; > %macro(month=200703); > > I tried something like this but didn’t work. > Is any way to combine macros with X to get all in only one automatic >program? > > Thanks, >Guido (From Argentina).

As others have pointed out, there are some basic problems with your code.

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 shelling out to a child process to muck about with the files and dirs. You might start with the DCREATE() function.

HTH, David -- David L. Cassell mathematical statistician Design Pathways 3115 NW Norwood Pl. Corvallis OR 97330

_________________________________________________________________ Exercise your brain! Try Flexicon. http://games.msn.com/en/flexicon/default.htm?icid=flexicon_hmemailtaglineapril07


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