Date: Fri, 12 Mar 2010 18:55:12 -0500
Reply-To: Ya Huang <ya.huang@AMYLIN.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ya Huang <ya.huang@AMYLIN.COM>
Subject: Re: 'Relative' %include statements to assign libraries.
Ooops, it should be ">c:\temp\t2\code"
On Fri, 12 Mar 2010 18:53:25 -0500, Ya Huang <ya.huang@AMYLIN.COM> wrote:
>I did a test, and I think this method could be useful if you don't
>have any format catalog that really need to define a libname.
>
>I created two similar directory trees:
>
>c:\temp\t1\data
>c:\temp\t1\code
>
>c:\temp\t2\data
>c:\temp\t3\code
>
>In each of the data folder, I have a dataset called xx,
>but they have different contents, basically SEX=M and SEX=F
>from sashelp.class.
>
>
>Now I have a code called printme.sas:
>
>data vv;
> set "..\data\xx";
>run;
>
>proc print;
>run;
>
>Copy it into both of the code folder, then batch submit the code in each
>folder, you will get printme.lst in both folder, but their contents
>reflect the data in the corresponding data folder (one for F, one for M).
>
>Here I used direct reference to the dataset (path\file name),
>but path is relative.
>
>In most real life situation, we may also need to define libname
>for format catalog or other catalog, then direct reference
>won't work (? does it?)
>
>
>
>On Fri, 12 Mar 2010 14:52:10 -0700, JD <jdiebal@GMAIL.COM> wrote:
>
>>I guess I'm not seeing this clearly. The code from Joe Matise does return
>>the path of the current program if not running from a batch program but
>>these will be called by a windows scheduler so it has to be 'batch
driven'.
>>And even if it did work from a batch job, I don't see how it could be
>>incorporated into the program to work properly.
>>
>>As far as the autoexec route: I don't see how that works either for this
>>problem. Just to clarify a bit more: The folder for Production jobs will
>end
>>up with lots of jobs and also subfolders within the main folder that have
>>their own jobs. In both the main folder and within each subfolder I would
>>like to put a libnames sas file that contains the relevant libraries.
After
>>testing the job in question in the Test folder I need to be able to simply
>>copy that sas job to it's counterpart in the Production folder. The
>sticking
>>point is that there will be no code changes once the test job has been
>>validated. If we could make code changes I'd simply put the appropriate
>>libanames in each job and then change them from the test libraries to the
>>production libraries at the time of putting them into production.
>>
>>Bottom line, once a job folder has been setup in the test and production
>>path (e.g. 'D:\TESTJOBS\90MINJOBS\' AND 'D:\PRODJOBS\90MINJOBS\') each
will
>>contain a libnames.sas file containing their respective libnames. Whatever
>>job has to run will contain a '%include' for the libnames file so it picks
>>up the libnames sas file that is in the relative folder.
>>
>>If I copy a file from the 90MINJOBS folder in TESTJOBS to the same
location
>>in the PRODJOBS folder, kickoff the job via windows scheduler, it will
>>simply pickup the libnames.sas folder in whatever folder the job is run
>>from. No code changes required. Or doesn't this whole thing make sense.
>>Sorry to belabor this issue and thanks for the responses.
>>
>>On Fri, Mar 12, 2010 at 12:32 PM, Fehd, Ronald J. (CDC/OSELS/NCPHI) <
>>rjf2@cdc.gov> wrote:
>>
>>> an autoexec is the way to handle assigning global statements like
>>> filename and libname
>>>
>>> Batch Processing under Windows
>>>
>>> TinyUrl: http://tinyurl.com/6zlqoh
>>>
>>> http://www.sascommunity.org/wiki/Batch_processing_under_Windows
>>>
>>>
>>> Ron Fehd the macro maven CDC Atlanta GA USA RJF2 at cdc dot gov
>>>
>>> > -----Original Message-----
>>> > From: owner-sas-l@listserv.uga.edu [mailto:owner-sas-
>>> > l@listserv.uga.edu] On Behalf Of JD
>>> > Sent: Friday, March 12, 2010 11:07 AM
>>> > To: sas-l
>>> > Subject: 'Relative' %include statements to assign libraries.
>>> >
>>> > Need:
>>> > I have sas jobs that need to be tested. The jobs in the test folder
>>> > will
>>> > point to test libraries.
>>> > I will then move those jobs to a production folder where they will
>>> > point to
>>> > production libraries. I do not want to change the libnames when moving
>>> > it.
>>> > Rather I'd like to simply put a libnameAssignment.sas file pointing to
>>> > test
>>> > libs in one and same file name pointing to production libs in the
>>> > other.
>>> > Then, if the SAS job had a "%include" with relative references
>>> pointing
>>> > to
>>> > the libNames.sas file, the job could be moved with no changes.
>>> >
>>> > There are probably better ways to do the above so feel free to ignore
>>> > everything after this line if there is a good, standard method of
>>> doing
>>> > this
>>> > already. thanks in advance
>>> >
>>> >
>>> >
>>> > If I set my environment variable to something like:
>>> >
>>> > Variable Name: tempProd
>>> >
>>> > Variable value: c:\
>>> >
>>> >
>>> >
>>> > And then put the batch job and libname.sas program in the
>>> "C:\TempProd"
>>> > folder and kick off the job, it works.
>>> >
>>> >
>>> >
>>> > Here is the batch job:
>>> >
>>> > %include '..\tempProd\libNames.sas';
>>> >
>>> > sas code
>>> >
>>> > .
>>> >
>>> > .
>>> >
>>> > .
>>> >
>>> > sascode
>>> >
>>> >
>>> >
>>> > Here is the contents of the libNames.sas file (which will change
>>> > depending
>>> > if it is in the Test or Prod folder):
>>> >
>>> > libname dmApp odbc dsn=datamart18 schema='APP' insertbuff = 2000;
>>> >
>>> >
>>> >
>>> > libname C520 odbc dsn=datamart schema='C520' ;
>>> >
>>> >
>>> >
>>> > My problem is that the jobs will not reside on the 'C' drive. They
>>> will
>>> > reside on a network drive somewhere. If I could put that network path
>>> > in the
>>> > Variable Name in the environment variable it would work but it doesn't
>>> > recognize it. I'm guessing that the enviornment variable is only good
>>> > for
>>> > the PC the SAS system is loaded on.
>>>
|