As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.


Here are some tips for How to share your SAS knowledge with your professional network.


Difference between revisions of "Autoexec Companion"

From sasCommunity
Jump to: navigation, search
(added programs before MWSUG 2015)
(add note about Autoexec file)
 
(One intermediate revision by one user not shown)
Line 3: Line 3:
  
 
==autoexec.sas==
 
==autoexec.sas==
 
+
For more information on the [[SAS]] autoexec file, see [[Autoexec file|this page]].
 
<source lang="sas">
 
<source lang="sas">
 
title1  'An autoexec.sas Companion';
 
title1  'An autoexec.sas Companion';
Line 128: Line 128:
  
 
==References==
 
==References==
* [[SASautos_Companion_Reusing_Macros]]
+
* [[SASautos Companion Reusing Macros]]
  
 
--[[User:Ron.Fehd.macro.maven|Ronald_J._Fehd macro.maven &#61;&#61; the radical programmer]] ([[User talk:Ron.Fehd.macro.maven|talk]]) 08:07, 7 October 2015 (CDT)
 
--[[User:Ron.Fehd.macro.maven|Ronald_J._Fehd macro.maven &#61;&#61; the radical programmer]] ([[User talk:Ron.Fehd.macro.maven|talk]]) 08:07, 7 October 2015 (CDT)
  
[[Category:Global_Symbol_Table]]
+
[[Category:Global Symbol Table]]
 +
[[Category:Autoexec File]]

Latest revision as of 10:16, 23 September 2016

MWSUG.2015 An Autoexec Companion, allocating location names during Startup

autoexec.sas

For more information on the SAS autoexec file, see this page.

title1   'An autoexec.sas Companion';
         %let %sysfunc(getoption(sysin,keyword));
         %put echo &=sysin;
title2   "&sysin";               *** path\program-name.sas;
title2   "%scan(&sysin,-2,/\.)"; *** program-name only;
 
         *** allocate environment variables;
               *** relative: sibling folder;
options  set = out_pdf   "..\out-pdf";    *   double quotes;
options  set = out_rtf   '..\out-rtf';    *or single quotes;
               *** absolute: hard-coded   compare to site_lib;
options  set = site_root 'C:\SAS-projects\SAS-site';
 
         *** various folders with input files;
filename in_csv  '..\csv';
filename in_dat  '..\dat';
filename project '.';* here: startup folder: *.sas programs;
         *** use bang (!) as prefix to reference an e-var;
filename site_inc "!site_root\includes";  *   double quotes;
filename site_mac '!site_root\macros'  ;  *or single quotes;
 
libname  library  '..\sas7b';               *sibling folder;
*libname  site_lib '!site_root\sas7b';
libname  site_lib '..\..\SAS-site\sas7b';*compare to site_root;
 
         *** functions compiled by proc fcmp in data set;
options  cmplib = library.functions;*or site_lib.functions;
 
         *** format catalogs, see also option fmterr;
options  fmtsearch = (work library site_lib.formats);
 
** pair  macro autocall: boolean, search-path filerefs;
options  mautosource
         sasautos = (project site_mac sasautos);
 
** pair  macros compiled and stored: boolean, one libref;
options  mstored  sasmstore = library;      *or site_lib;
 
options  nofmterr         %* no err msg: fmt missing;
         fullstimer       %* max info in timer block;
         msglevel = i     %* more messages in log   ;
         ;
 
options  nocenter         %* flush left output      ;
         nodate           %* no date-stamp          ;
         nonumber         %* no pages numbers       ;
         details          %* proc contents          ;
         formchar =       %* no special chars       ;
                          '-------------------'
         formdlim = ' '   %* no CR/LF for page break;
         linesize = max   %* for LaTeX printing     ;
         pagesize = max;  %* no page breaks in *.lst;

autoexec-test

autoexec-test.bat

sas autoexec-test -echoauto

autoexec-test.sas

**** name: autoexec-test.sas;
**** many options are set in configuration files;
%put echo sascfg=%sysget(sascfg);
%put echo %sysfunc(getoption(config,keyword));
 
*command-line option sasinitialfolder may be set by icons;
*or project config, compare to folder of fileref project;
%put echo %sysfunc(getoption(sasinitialfolder,keyword));
 
*review all filerefs;
filename _all_ list;
 
**** review cmplib=libref.data-set-name of functions;
%let %sysfunc(getoption(cmplib,keyword));
%sysfunc(ifc(%sysfunc(exist(&cmplib))
            ,%nrstr(%put echo exist(&cmplib);)
        ,%nrstr(%put echo not exist(&cmplib);),))
 
%let exist_catalog = %nrstr(echo
%sysfunc(ifc(%sysfunc(cexist(&catalog))
      ,,%nrstr(not ),))exist &catalog);
 
**** formats: search list of librefs;
%let %sysfunc(getoption(fmtsearch,keyword));*remove parens;
%let fmtsearch=%substr(&fmtsearch,2,%length(&fmtsearch)-2);
%put echo &=fmtsearch;
**** check default = work library;
%let catalog = work.formats;
%put %unquote(&exist_catalog);
%let catalog = library.formats;
%put %unquote(&exist_catalog);
**** remove default librefs WORK and LIBRARY;
%let fmtsearch=%sysfunc(tranwrd(&fmtsearch,WORK,%str( )));
%let fmtsearch=%sysfunc(tranwrd(&fmtsearch,LIBRARY,%str( )));
**** there may be one, or more;
%let fmt_lib = %scan(&fmtsearch,1,%str( ));
**** if fmt-lib has dot then is two-level name;
%let catalog = %sysfunc(ifc(%index(&fmt_lib,.)
     ,%nrstr(&fmt_lib),%nrstr(&fmt_lib..formats) ));
%put %unquote(&exist_catalog);
 
**** macro autocall;
%put echo mautosource=%sysfunc(getoption(mautosource));
%put echo %sysfunc(getoption(sasautos,keyword));
*allocate fileref sasautos to check if modified in config;
%include sasautos(af)/nosource2;
%put echo sasroot=%sysget(sasroot);
filename sasautos list;
**** if  sasautos contains paths other than sasroot
     then review configuration file(s) listed above;
 
**** macros compiled and stored;
%let mstored  =%sysfunc(getoption(mstored));
%let sasmstore=%sysfunc(ifc(&mstored eq MSTORED
     ,%nrstr(%sysfunc(getoption(sasmstore))),%nrstr(work)));
%put echo &=mstored &=sasmstore;
%let catalog = &sasmstore..sasmacr;
%put %unquote(&exist_catalog);

References

--Ronald_J._Fehd macro.maven == the radical programmer (talk) 08:07, 7 October 2015 (CDT)