Setting Up Project Config and AutoExec
From sasCommunity
This article examines the issues of moving hard-coded global statements from many programs into a project autoexec.
Contents |
[edit] Global Statements
These global statements are candidates for inclusion in a project autoexec.
- Titles and Footnotes
- FileNames
- Libnames
- Options
[edit] Titles and Footnotes
[edit] Placement on page
Choice: centering or flush left
options center; *default; options nocenter; *flush left;
See also: options linesize, pagesize, orientation.
[edit] Pagination
options noDate %* no date-stamp ;
DtReset %* date+time reset;
noNumber %* no page numbers;
;
Tip: use the macro function sysfunc to place a date-stamp in other than title1. Experiment with other datetime formats. Note the default is time + weekdate.
%Put %sysfunc(datetime(),datetime21.2));
Title2 "%sysfunc(datetime(),datetime21.2))";
Title3 "%sysfunc(time(),timeampm11.) "
"%sysfunc(date(),weekdate37.)";
run;
See Fehd's macro TextLine to justify (left, center, right) text in titles or footnotes:
http://www.listserv.uga.edu/cgi-bin/wa?A2=ind0212B&L=sas-l&P=R16544
[edit] Specifying more than one Directory-Specification
Note: both the filename and libname statements use the following syntax for specifying a list of directory-specifications, which must be enclosed in parenthesis.
*single;
filename Folder1 'c:\temp\sas';
*list: enclose in parenthesis;
filename Folders ('c:\temp1'
'c:\temp1');
[edit] FileNames
The filename statement is used to provide symbolic names of folders, which sas documentation refers to as directory-specification.
Common assignments:
Filename Project '.';*here: see option SASinitialFolder; Filename SiteIncl 'C:\SAS\site\includes';
Filerefs are used by option sasautos.
[edit] LibNames
Common assignments:
Libname Library '..\sas7b'; Libname LibWork (Work) ;
Librefs are used by options CmpLib and SASmStore.
[edit] Options
Any option used anywhere is a candidate for assignment in the autoexec.
options MsgLevel = I; * extra messages displayed;
[edit] Folder Naming Conventions
[edit] Site
Directory of C:\SAS\site 11/18/2005 01:01p <DIR> formats 11/18/2005 02:02p <DIR> functions 11/18/2007 03:03p <DIR> includes 11/18/2005 05:05p <DIR> MacroCatalog 11/18/2007 08:08p <DIR> macros 11/18/2007 13:13p <DIR> MacrosCompileAndStore
- formats: contains catalog: formats.sas7bcat
- functions: contains SAS data sets with functions compiled by proc fcmp
- Note: 9.2
- includes: contains utility programs
- MacroCatalog: contains catalog: sasmacro.sas7bcat
- macros: autocall: contains programs with macros
- MacrosCompileAndStore: contains programs with macros to store
[edit] Project
Directory of C:\SAS\projects\SetUpProject 11/18/2007 03:52p <DIR> sas 11/18/2005 03:51p <DIR> sas7b 11/18/2007 01:32p <DIR> sas7bWork
- sas: contains program text files
- sas7b: contains SAS-created files:
- catalogs: *.sas7bcat,
- data sets: *.sas7bdat,
- etc.
- sas7bWork: contains temporary data sets; used while testing;
[edit] Environmental Variable SASsite
[edit] Configuration file
In either of
- SASv8.cfg
- SASv9.cfg
you can allocate an environment variable using configuration file syntax
-set SASsite 'C:\SAS\Site'
[edit] autoexec
This environmental variable can be also allocated in the autoexec with this statement:
options set = SASsite 'C:\SAS\Site';
[edit] autoexec.sas examples
[edit] autoexec.sas accessing only project folders
*autoexec.sas;
Title1 'Fehd: Setup Project config and autoexec';
*Footnote1 '?';
options noCenter %* flush left output;
noDate %* no date-stamp ;
DtReset %* date+time reset ;
noNumber %* no page numbers ;
;
Filename Project '.';
Libname Library '..\sas7b';
Libname LibWork (Work) ;
options CmpLib = Library.functions;
options MautoSource %*macros: autocall: *.sas;
SASautos = (Project SASautos);
%*macros: stored : SASmacr.sas7bcat;
options Mstored SASmStore = Library;
options %*miscellaneous;
details %* Proc Contents ;
FormChar = %* no special chars ;
'-------------------'
FormDlim = ' ' %* no CR/LF for page break ;
LineSize = max %* no squeeze output ;
MsgLevel = I %* extra messages displayed;
PageSize = max %* no page breaks in *.lst ;
;
[edit] autoexec.sas for a project accessing site folders
*autoexec.sas;
Title1 'Fehd: Setup Project config and autoexec';
*Footnote1 '?';
options noCenter %* flush left output;
noDate %* no date-stamp ;
DtReset %* datetime reset ;
noNumber %* no page numbers ;
;
Filename Project '.';
Filename SiteIncl '!SASsite\includes';
Libname Library '..\sas7b';
Libname LibWork (Work) ;
Libname SiteFmts '!SASsite\formats';
options FmtSearch = (Work Library SiteFmts);
Libname SiteFunc '!SASsite\functions';
options CmpLib = (Library.functions
SiteFunc.functions);
options MautoSource %* macros: autocall: *.sas;
SASautos = (Project '!SASsite\macros'
SASautos);
%* macros: stored: SASmacr.sas7bcat;
Libname SiteMacr '!SASsite\MacroCatalog';
options Mstored
SASmStore = (Library SiteMacr);
options %* miscellaneous;
details %* Proc Contents ;
FormChar = %* no special chars ;
'-------------------'
FormDlim = ' ' %* no CR/LF for page break ;
LineSize = max %* no squeeze output ;
MsgLevel = I %* extra messages displayed;
PageSize = max %* no page breaks in *.lst ;
;
[edit] References
- Writing Testing-Aware Programs that Self-Report when Testing Options are True,
Ronald Fehd. http://www.nesug.info/Proceedings/nesug07/cc/cc12.pdf
- Systems Options Are Your Friends, Edward Heaton,
http://www2.sas.com/proceedings/sugi28/067-28.pdf
--macro maven == the radical programmer 16:07, 28 November 2007 (EST)
