Published on :

Dynamic SAS Environment Configuration

This code is also available in: Deutsch Español Français
Attention : This code requires administrator privileges.
The '%AHGsetauto' macro is designed to adjust global SAS© session options. It uses conditional logic ('%if %upcase(&theuser)=LIUH04') to apply a specific set of options if the user is 'LIUH04', or a default set otherwise. Configured options include disabling date and page number display ('nodate nonumber'), disabling log centering ('nocenter'), enabling automatic macro search ('mautosource'), and specifying missing values ('missing=' '). It also defines filerefs for project paths ('filename someauto'). The 'sasautos' options are crucial as they specify the ordered list of directories where SAS© should search for autocall macro definitions, including system paths, custom user paths, and project-specific paths. The 'fmtsearch' option defines the search order for SAS© format catalogs. Finally, the log line width is set to 180 characters ('ls=180') and error messages related to unfound formats are disabled ('nofmterr').
Data Analysis

Type : EXTERNE


This script does not directly manipulate SAS datasets. Its role is to configure the paths where SAS will search for external macro files (via sasautos) and external format catalogs (via fmtsearch) that will be necessary for the execution of other SAS programs. It neither creates nor reads transactional data.

1 Code Block
MACRO DEFINITION
Explanation :
This block contains the definition of the 'AHGsetauto' macro. It integrates conditional logic ('%if...%then...%else') to adapt configurations based on the value of the macro variable '&theuser'. Inside these conditional blocks, various SAS options are defined to control session behavior. These include display options ('nodate nonumber nocenter'), macro management ('mautosource', 'sasautos'), data handling ('missing=' '), and format searching ('fmtsearch'). The 'filename someauto' statement creates a shortcut to local file paths. The 'sasautos' and 'fmtsearch' options are lists of paths, defining where SAS should search for autocall macro files and format catalogs, respectively, mixing system paths ('!sasroot'), user paths, and project paths. The 'ls=180' and 'nofmterr' options adjust the log line width and format error handling, respectively.
Copied!
1%macro AHGsetauto(mode=allLib /*AllLib onlyMac onlyAna*/);
2 
3 %IF %upcase(&theuser)=LIUH04 %THEN
4 %DO;
5 options nodate nonumber nocenter mautosource missing=' ' ;
6 filename someauto ("&projectpath\\analysis" "&projectpath\\extract" "&projectpath\\macros");
7 option
8 sasautos=( %IF &mymac ne %THEN "&mymac"; sasautos '!sasroot/sasautos'
9 "&kanbox\\my sas files\\macros" "&kanbox\\allover " "&kanbox\\alloverhome" '!sasroot\\base\\sasmacro' someauto "&preadonly\\pds1_0\\macros" /*gmac hctools*/ sasautos )
10 ;option fmtsearch=(work.formats library GCAT.GROFMTS GCAT.INTV6 GCAT.INTV5 GCAT.CSA608) cmdmac;
11 option ls=180;
12 option nofmterr;
13 %END;
14 %ELSE
15 %DO;
16 
17 
18 
19 options nodate nonumber nocenter mautosource missing=' ' font=("Courier New" 9)
20 sasautos=( %IF &mymac ne %THEN "&mymac"; '!sasroot/sasautos' '!sasroot\\base\\sasmacro' "&projectpath\\analysis" "&readonly\\pds1_0\\macros" "&projectpath\\extract" "&projectpath\\macros" '!sasroot\\base\\sasmacro' /*gmac hctools*/ sasautos /*_my*/ )
21 fmtsearch=(work.formats ) cmdmac;
22 /*%b_formats;*/
23 
24 option ls=180;
25 option nofmterr;
26 
27 
28 %END;
29%mend;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.