The macro does not process data per se, but interacts with the SAS Drive file system (folder existence metadata). No external data is read or created within the macro itself for analytical processing.
1 Code Block
MACRO (mf_abort)
Explanation : This block checks the value of the `&syscc` system variable. If `&syscc` is not zero (indicating a previous error), the `mf_abort` macro is called to stop execution and display an error message. This ensures that the `mfv_existfolder` macro does not run if the environment is already in an error state.
Copied!
%mf_abort(
iftrue=(&syscc ne 0),
msg=Cannot enter mfv_existfolder.sas with syscc=&syscc
)
1
%mf_abort(
2
iftrue=(&syscc ne 0),
3
msg=Cannot enter mfv_existfolder.sas with syscc=&syscc
4
)
2 Code Block
MACRO
Explanation : Declares the local macro variables `fref`, `rc`, and `var`. The `fref` variable is then assigned a unique fileref via the `mf_getuniquefileref` macro to avoid conflicts and ensure the uniqueness of the temporary fileref.
Explanation : This block is the core of the macro. It attempts to assign a fileref (`fref`) to a folder path (`&path`) on SAS Drive using the `filesrvc` engine. The `filename` function returns 0 if the assignment is successful (which indicates that the folder exists). If the folder exists, the macro returns the value '1'. If the folder does not exist, the `filename` function sets `&syscc` to a non-zero value; the macro then resets `&syscc` to 0 in the `%else` block to prevent this failure from affecting future operations. The `var` variable and the fileref are cleaned up after use.
Explanation : This block re-checks the value of `&syscc` before exiting the macro. If `&syscc` is non-zero, the `mf_abort` macro is called to signal an error, indicating a problem that occurred during the execution of the `mfv_existfolder` macro's body.
Copied!
%mf_abort(
iftrue=(&syscc ne 0),
msg=Cannot leave mfv_existfolder.sas with syscc=&syscc
)
1
%mf_abort(
2
iftrue=(&syscc ne 0),
3
msg=Cannot leave mfv_existfolder.sas with syscc=&syscc
4
)
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.