Published on :

Environment Configuration and Dependency Loading

This code is also available in: Deutsch Español Français
Attention : This code requires administrator privileges.
The script defines a `%setPathToCurrent` macro that attempts to retrieve the path of the currently executing file via an environment variable and adjust the system's working directory (cd). It then defines a 'survey' library pointing to a relative folder, configures format search options, and includes a series of SAS© files (macros) located in parent or shared directories. Note: The use of backslashes in path parsing suggests a Windows origin, which may require adaptation for a Linux/Viya environment.
Data Analysis

Type : MIXTE


Uses system commands for the path, defines an external local 'survey' library ('../data'), and loads code via %include.

1 Code Block
MACRO
Explanation :
Definition of the `setPathToCurrent` macro. It retrieves the full path of the executed file, extracts the parent folder (Windows logic with '\'), and uses `call system` within a `data _null_` to change the operating system's working directory.
Copied!
1%let currentDir=;
2 
3%macro setPathToCurrent;
4 %local cdir cFileName cFileBaseName n_cFileName n_pathName cPathName;
5
6 %let cFileName = %sysget(sas_execfilepath);
7 %let cFileBaseName = %qscan(&cFileName, -1, '\');
8 %let n_cFileBaseName = %length(%quote(&cFileBaseName));
9 %let n_cFileName = %length(%quote(&cFileName));
10 %let n_pathName = %eval(&n_cFileName - &n_cFileBaseName - 1);
11 %let cPathName = %qsubstr(&cFileName, 1, &n_pathName);
12
13 data _null_;
14 call system("cd &cPathName");
15 RUN;
16 
17 %let currentDir = &cPathName;
18 
19%mend setPathToCurrent;
2 Code Block
GLOBAL STATEMENTS
Explanation :
Execution of the configuration macro, definition of the 'survey' library, configuration of format options, and inclusion of external code files (shared macros).
Copied!
1%setPathToCurrent;
2 
3LIBNAME survey "../data";
4 
5options fmtsearch = (work fdz) mstored sasmstore = sasuser;
6 
7%include "./macrro_gregg.sas"; /*MACRO GREGAR*/
8%include "../CLAN/clan97_313.sas";
9%include "../shared/utility_macros1.sas";
10%include "../shared/buildAuxData.sas";
11%include "../shared/parseModel.sas";
12%include "../shared/vec_emu.sas";
13%include "../shared/interaction.sas";
14 
15/*%include "./shared/stack.sas";*/
16%include "../shared/buildTotalsTable.sas";
17%include "../shared/combineTables.sas";
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.