Date: Tue, 28 Oct 1997 17:37:14 -0500
Reply-To: Ed Heaton <edheaton@FENIX2.DOL-ESA.GOV>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Ed Heaton <edheaton@FENIX2.DOL-ESA.GOV>
Subject: Re: Good SAS Coding Practices
I once used the two-part WORK.xxxx data set names for temporary data sets.
However, I found that I often needed to keep those data sets while I was
working on the programs. Then I could rerun the program starting at the
location of a problem (or change) without hogging up system resources by
rerunning the whole job. So I now use the one-part name for temporary data
sets so that I can easily convert them back and forth from temporary to
permanent by calling (or not calling) the following macro:
%*-----------------------------------------------------------------* ;
%* MACRO: TESTLIB
%*
%* USAGE: %testlib(dslevel,job<,space= ><,disp= >) ;
%* The angle-braces delineate optional parameters.
%*
%* PROGRAMMER:
%* Edward Heaton, Systems Development Specialist,
%* CDSI Information Technology Solutions Company
%* (a division of Computer Data Systems, Inc.),
%* on contract at U.S. Department of Labor, Room C-3312,
%* 200 Constitution Avenue, Northwest, Washington, DC 20210.
%* (202) 219-5572 edheaton@fenix2.dol-esa.gov
%*
%* STORAGE:
%* This macro is stored in %dslevel..FECA.AUTOCALL.LIB(TESTLIB)
%* on
%*
%* DESCRIPTION:
%* This external SAS macro assigns a libref to a SAS library for
%* testing the job that calls it. If the library does not exist,
%* use disp=(NEW,CATLG,KEEP) instead of the default disp=NEW.
%* This macro then sets this library as the USER library. It
%* requires input of the DSLEVEL and the job name. You can also
%* change the default SPACE from 20 cylinders primary and 20
%* cylinders secondary extents with the SPACE= option. This
%* macro will only work when called from jobs running in the MVS
%* environment.
%*-----------------------------------------------------------------* ;
%* * * * * * A U D I T T R A I L * * * * *
%* 19970616 EH : Created macro.
%*-----------------------------------------------------------------* ;
%MACRO /* Begins the definition of a
macro, assigns the macro a
name, and may optionally
include a parameter list of
macro variables, a list of
options, or both. */
testlib ( /* macro name */
dslevel /* The first field of the file
name. This should be common
throughout this job. */
, job /* The name of this job. This
will identify this file as a
test library for this
particular job. */
, space= 20 /* The primary and secondary
space allocation, in
cylinders. */
, disp= OLD /* The file disposition: use the
default if the file already
exists; otherwise use
DISP=(NEW,CATLG,DELETE). */
) ;
%*-----------------------------------------------------------------* ;
LIBNAME test /* Associates a SAS libref with
a SAS data library. */
"&dslevel..&job..test.data" /* OS data set name */
UNIT= 3380 /* device name */
SPACE= (CYL,(&space,&space)) /* Specifies how much disk space
to provide for a data set
that is being created. */
DISP= &disp /* Specifies the status of the
data set at the beginning and
ending of a job, as well as
what to do if the job
terminates abnormally. */
;
%* Check the contents of this SAS data library, if it pre-exists. ;
%IF ("&disp" EQ "OLD") %THEN %DO ;
PROC CONTENTS /* Prints descriptions of the
contents of files from a SAS
library. */
DATA= test._ALL_ /* Specifies the data set name
or _ALL_ for all members of
the library. */
NODS /* Do not list contents of
datasets. */
;
RUN ; /* Executes the previously
entered SAS statements. */
%END ; /* "&disp" EQ "OLD" */
OPTIONS /* Changes the value of SAS
system options. */
USER= test /* Specifies the default
library. */
;
%*-----------------------------------------------------------------* ;
%MEND testlib ; /* Ends a macro definition. */
%*-----------------------------------------------------------------* ;
Edward Heaton, Systems Development Specialist,
CDSI Information Technology Solutions Company
(A Division of Computer Data Systems, Inc.),
on contract at U.S. Department of Labor, Room C-3312,
200 Constitution Avenue, Northwest, Washington, DC 20210
(202) 219-5572 edheaton@fenix2.dol-esa.gov
Date: Tue, 28 Oct 1997 08:09:25 PST
From: William Viergever <wwvierg@IBM.NET>
Subject: Re: Good SAS Coding Practices
Addressed to: Joel Achtenberg <joel@WUBIOS.WUSTL.EDU>
SAS-L@UGA.CC.UGA.EDU
** Reply to note from Joel Achtenberg dated Tue, 28 Oct 1997 09:48:10 -0600
> Here's one more...my prejudice, with which I'm sure others may disagree:
Avoid one-part dataset names for work datasets. Using WORK.XXXXX makes it
easy to search your code for temporary datasets, and make global changes if
necessary.
On mainframes I would agree b/c you often need to "point" to specific dasds
for "work"; on a PC I've become quite a bit more relaxed <g>.
Actually I'm partial ("prejudice" seems so harsh in this PC world) to a
simple progression of "tmp01" - "tmpN" which seems sufficient to ID temp
datasets and you still can "point" to different "work" areas.
Just my $0.02
Later
W.W. Viergever
Principal
Viergever & Associates
Sacramento, CA
(916) 923-2355
|