Setting Up Site Autoexec

From sasCommunity
Jump to: navigation, search
  • description: setting up site files
    • autosite.sas
    • sas.bat
    • sas.cfg
  • purpose: standardize naming conventions across all projects

see also:

Here are the steps in the process:

  1. make directories:
    1. SAS-site
    2. SAS-site\includes
    3. SAS-site\macros
    4. SAS-site\sas
    5. SAS-site\sas7b
    6. SAS-site\sas-include-tests
    7. SAS-site\sas-macro-tests
  2. make files:
    1. SAS-site\autosite.sas
    2. SAS-site\sas.bat
    3. SAS-site\sas.cfg


Z:\SAS-site

The project folder SAS-site contains folders for site-includes and site-macros. and these files:

  • autosite.sas
  • sas.bat
  • sas.cfg

Listing: Files and Folders

This is an overview of the files and folders.

<UNC>\SAS-site
               files
<UNC>\SAS-site\autosite.sas
              \SAS.bat
              \SAS.cfg
              
               folders
              \includes
              \macros
              \sas-include-tests
              \sas-macro-tests
              \sas
              \sas7b

This is the directory listing:

Directory of <UNC>\SAS-site
06/10/2012  05:52 PM    <DIR>          .
06/10/2012  05:52 PM    <DIR>          ..
06/10/2012  08:49 AM             1,508 autosite.sas
06/10/2012  10:15 AM    <DIR>          includes
05/30/2012  02:56 PM    <DIR>          macros
06/10/2012  05:49 PM    <DIR>          sas
06/10/2012  05:49 PM    <DIR>          sas-include-tests
06/10/2012  05:48 PM    <DIR>          sas-macro-tests
06/10/2012  05:49 PM    <DIR>          sas-new-task
05/01/2012  10:12 AM               933 sas.bat
06/10/2012  10:03 AM               566 sas.cfg
10/19/2011  06:09 AM    <DIR>          sas7b

Note: sas7b is the folder for catalogs: *.sas7bdat and data sets: *.sas7bdat.

Files

  • sas.bat
  • sas.cfg
  • autoexec.sas
set SAS-exe="C:\Program Files\SASHome\SASFoundation\9.3\SAS.exe"
if     exist %SAS-exe% (%SAS-exe% %*) else echo SAS.exe not found
if not exist %SAS-exe% pause
exit
 
rem        name: <UNC>\SAS-site\SAS.bat
rem description: start SAS and pass all command-line parameters 
rem              Windows %* :: pass all parameters
rem     purpose: centralize version of SAS used by all projects
rem   called by: SAS.bat in each project folder
rem       OpSys: Windows XP
rem usage:
rem ..\..\SAS-site\sas %*
rem rem name: project SAS.bat

set SAS-exe="C:\Program Files\SASHome\SASFoundation\9.3\SAS.exe"
set SAS-exe="C:\Program Files\SAS\SASFoundation\SAS 9.2\SAS.exe"
set SAS-exe="C:\Program Files\SAS\SASFoundation\9.2\SAS.exe"
set SAS-exe="C:\Program Files\SAS\SAS Learning Edition 4.1\sas.exe"
set SAS-exe="C:\Program Files\SAS\SAS 9.1\SAS.exe"
set SAS-exe="C:\Program Files\SAS Institute\SAS\V8\SAS.exe" %*
/*name: Z:\SAS-site\sas.cfg
  RJF2 2012-Apr-30 */
-set Projects_UNC '\\OurCompany\SAS-projects\'
-set Proj_Name    'uninitialized'
-set Proj_Task    'sas'

-autoexec '!Projects_UNC\SAS-site\autosite.sas'

Note: environmental variables can be referenced with

  • a bang or exclamation point as prefix: !evar, in configuration files: *.cfg
  •  %sysget(evar) in programs: *.sas
 /*    name: Z:\SAS-site\autosite.sas;
description: autoexec for all project tasks
    purpose: standardize naming conventions
                         access to site folders with includes, macros
       note: calls Project(autoexec)
********/
filename Project
         "%sysget(Projects_UNC)\%sysget(Proj_Name)\%sysget(Proj_Task)";
filename SiteIncl (
         "%sysget(Projects_UNC)\%sysget(Proj_Name)\%sysget(Proj_Task)"
         "%sysget(Projects_UNC)\SAS-site\includes");
filename SiteMacr (
         "%sysget(Projects_UNC)\%sysget(Proj_Name)\%sysget(Proj_Task)"
         "%sysget(Projects_UNC)\SAS-site\macros");
%sysfunc(
    ifc(%sysfunc(getoption(EchoAuto)) eq ECHOAUTO
       ,%nrstr(filename Project  list;
               filename SiteIncl list;
               filename SiteMacr list;
               options  source2;
              )
       ,))
 
* macro autocall is list of filerefs;
options mautosource
        sasautos = (Project SiteMacr SASautos);
 
*note: required in other config file: -rtrace all;
*note: rtraceloc is name of *-this-* rtrace log  keys are in filename;
*options rtraceloc =
        "!SaveRtrace\%sysget(computername)_%substr
                           (&SysProcessId.,1,16)_&SysUserId..log";
 
libname Library
         "%sysget(Projects_UNC)\%sysget(Proj_Name)\sas7b";
libname LibSite
         "%sysget(Projects_UNC)\LibSite\sas7b";
 
* macros compiled and stored in libref.SASmacr.sas7bcat;
*libname LibMacro "%sysget(Projects_UNC)\SAS-site\macrocat";
*options Mstored
         SASmStore = LibMacro;
 
* title1 set by project.autoexec;
%Include Project(autoexec);
 
* write notes to log of global macro variables set by task.autoexec;
%Include SiteIncl(put-user);
 
* add name of program to title2;
Title2
%sysfunc(ifc("%sysfunc(getoption(SysIn))" ne ""
            ,%nrstr(%sysfunc(getoption(SysIn)))
            ,%nrstr(%sysget(SAS_EXECFILEPATH))
        )   );
* title3:10 set in programs;

Testing in a Project-Task folder

  • sas.bat
  • SASv9.cfg
  • 00-autoexecTest.bat
  • 00-autoexecTest.sas
  • 00-autoexecTest.log excerpts
..\..\SAS-site\sas %*
rem name: project.task\sas.bat
rem '..\..\' means up two levels to folders of projects
/*name: <UNC>\<Project>\<task>\SASv9.cfg */
-config ..\..\SAS-site\sas.cfg
-set Proj_Name 'SAS-site'
-set Proj_Task 'sas-include-tests'
rem name: 00-autoexecTest.bat
sas 00-autoexecTest -echoauto
*name: 00-autoexecTest.sas;

Log

NOTE: AUTOEXEC processing beginning; 
      file is Z:\SAS-site\autosite.sas.
....
39         %Include Project(autoexec);
NOTE: %INCLUDE (level 1) file PROJECT(autoexec) 
      is file Z:\SAS-site\sas-include-tests\autoexec.sas.
....
NOTE: %INCLUDE (level 1) ending.
....
NOTE: AUTOEXEC processing completed.

References

--Ronald_J._Fehd macro.maven == the radical programmer 10:22, 12 June 2012 (EDT)