The script interacts with the SAS metadata server for folder creation and verification. It uses the system options `metaserver` and `metaport` for connection. Additionally, it executes an external system command (`sas-make-folder`) via the `pipe` instruction, which implies interaction with the underlying operating environment. It does not process traditional external data files (CSV, Excel, etc.) that would not be managed by the script itself or SASHELP libraries.
1 Code Block
MACRO CALL / DATA STEP
Explanation : This block initializes local macro variables (`host`, `port`, `path`, `connx_string`, `msg`). It retrieves the SAS metadata server host and port via the `getoption` function. It then constructs the connection string (`connx_string`) including the provided credentials, and a path (`path`) to an external `sas-make-folder` tool (the `%mf_loc` macro is an external dependency). A `DATA _NULL_` step is used with the `infile ... pipe` instruction to execute the external `sas-make-folder` command with the defined parameters, in order to create the metadata folder. The command's output is directed to the SAS log via `putlog _infile_`.
Explanation : This block proceeds with folder creation verification and error handling. A `DATA _NULL_` step uses the `metadata_pathobj` function to query the metadata server for the type of object existing at the location specified by `&loc`. The result, indicating the object type (e.g., 'Tree' for a folder), is stored in the local macro variable `foldertype` via `call symputx`. If `foldertype` is not 'Tree', the `%mp_abort` macro (an error-reporting termination macro) is called, indicating that the location was not created correctly.
Copied!
data _null_; /* check tree exists */
length type uri $256;
rc=metadata_pathobj("","&loc","Folder",type,uri);
call symputx('foldertype',type,'l');
run;
%let msg=Location (&loc) was not created!!;
%mp_abort(iftrue= (&foldertype ne Tree)
,mac=&_program..sas
,msg=%superq(msg)
)
1
DATA _null_; /* check tree exists */
2
LENGTH type uri $256;
3
rc=metadata_pathobj("","&loc","Folder",type,uri);
4
call symputx('foldertype',type,'l');
5
RUN;
6
%let msg=Location (&loc) was not created!!;
7
%mp_abort(iftrue= (&foldertype ne Tree)
8
,mac=&_program..sas
9
,msg=%superq(msg)
10
)
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.