The script neither uses nor creates data in the sense of traditional SAS datasets. Its purpose is to interact with the metadata of the SAS Drive file system to check for the existence of an object (file), whose path is provided as a parameter.
1 Code Block
Macro Call (%mf_abort)
Explanation : This block calls the `%mf_abort` macro to check if the `&syscc` system macro variable (error return code) is non-zero. If so, it indicates a previous error, and the macro stops, thus avoiding executing the code in an error state.
Copied!
%mf_abort(
iftrue=(&syscc ne 0),
msg=Cannot enter mfv_existfile.sas with syscc=&syscc
)
1
%mf_abort(
2
iftrue=(&syscc ne 0),
3
msg=Cannot enter mfv_existfile.sas with syscc=&syscc
4
)
2 Code Block
Macro Variable Manipulation
Explanation : This block declares local macro variables (`fref`, `rc`, `path`, `name`). It initializes `fref` with a unique file reference generated by `%mf_getuniquefileref()`. The `%scan` and `%substr` macro functions are used to extract the file name (`name`) and its path (`path`) from the provided `filepath` parameter.
Explanation : This conditional block attempts to assign the fileref (`fref`) to the specified file on SAS Drive using the `filename()` function with the `filesrvc` engine. If the assignment is successful (returns 0), `fexist(&fref)` is called to check for the file's existence, and its result is returned. If the assignment fails, the macro returns `0`, and the `&syscc` macro variable is explicitly reset to `0`.
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.