The script does not directly use external SAS datasets. The two 'DATA _NULL_' steps are used to execute system commands and manipulate file paths, without creating persistent datasets. The processed data primarily consists of file metadata (SAS filenames) and access paths.
1 Code Block
DATA STEP
Explanation : This SAS Data Step block, which does not create a persistent dataset ('_NULL_'), uses the `filename pip pipe 'dir ...'` function to execute the system command 'dir' and list '.sas' filenames in the 'core' directory defined by `kanbox`. Filenames are read one by one. It includes logic to exclude 'refreshmac.sas' and to filter files if the `&files` parameter is provided. For each relevant file, it constructs an `%include` command and executes it dynamically via `call execute`, allowing other macros or SAS code to be included.
Copied!
data _null_;
filename pip pipe "dir "&kanbox\core\*.sas " /b";
infile pip;
length file $100 com $300;
input file ;
if index(file,'refreshmac.sas') then return;
if ("&files" ne '') and (not index(upcase("&files"),trim(upcase(file)))) then return;
com=("%include "&kanbox\core\"||file||"';");
put com=;
call execute(com);
run;
1
DATA _null_;
2
filename pip pipe "dir "&kanbox\core\*.sas " /b";
3
INFILE pip;
4
LENGTH file $100 com $300;
5
INPUT file ;
6
IF index(file,'refreshmac.sas') THEN return;
7
IF ("&files" ne '') and (not index(upcase("&files"),trim(upcase(file)))) THEN return;
8
com=("%include "&kanbox\core\"||file||"';");
9
put com=;
10
call execute(com);
11
RUN;
2 Code Block
DATA STEP
Explanation : Similar to the previous block, this second Data Step also uses a 'DATA _NULL_' to dynamically list and include '.sas' files. The only difference is that it targets the 'inter' directory instead of 'core' within the `kanbox` path, performing the same filtering and dynamic inclusion logic for macros or code located in this directory.
Copied!
data _null_;
filename pip pipe "dir "&kanbox\inter\*.sas " /b";
infile pip;
length file $100 com $300;
input file ;
if index(file,'refreshmac.sas') then return;
if ("&files" ne '') and (not index(upcase("&files"),trim(upcase(file)))) then return;
com=("%include "&kanbox\inter\"||file||"';");
put com=;
call execute(com);
run;
IF ("&files" ne '') and (not index(upcase("&files"),trim(upcase(file)))) THEN return;
8
com=("%include "&kanbox\inter\"||file||"';");
9
put com=;
10
call execute(com);
11
RUN;
3 Code Block
Macro and system commands
Explanation : This block defines local variables for network paths (`SAdrive`, `macbackup`) and allocates a `netmac` libname to the macro backup directory. It then uses two macros (`%AHGdateandtime`, `%AHGpm`) to generate a date/time in the `mydt` variable (not provided, assumed to exist elsewhere). Crucially, it executes system commands via the `x` statement: `x mkdir` to create a new timestamped directory for the backup, and `x copy` to copy existing library files to this new backup directory. Finally, `PROC DATASETS` is used to copy all catalogs (which contain compiled macros) from the temporary 'work' library to the 'netmac' libname, thereby ensuring the macro library is backed up and refreshed.
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.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.