The macro itself does not read or create data; it verifies their existence. The validation block, provided in a comment, creates temporary test datasets (`WORK.DATA_n`, `PWD.TEST2`) to verify the macro's proper functioning.
1 Code Block
MACRO
Explanation : Definition of the _dsexist macro. It takes a dataset name as an argument. It extracts the library and table name, then applies conditional logic: specific processing for dictionary views of the SASHELP library, a fixed return value for a 'DB' library, and a check for the physical file's existence for all other libraries.
Explanation : Part of the validation flow (commented out). This block first assigns the 'PWD' library to the current directory. Then, it creates an empty dataset in the WORK library (automatically named data1, data2, etc.) and another empty dataset named 'test2' in the 'PWD' library.
Copied!
/* uncomment to re-validate
libname pwd '.';
data;
run;
data pwd.test2;
run;
1
/* uncomment to re-validate
2
3
LIBNAME pwd '.';
4
5
DATA;
6
RUN;
7
8
DATA pwd.test2;
9
RUN;
3 Code Block
MACRO CALL
Explanation : Part of the validation flow (commented out). This block executes a series of tests by calling the %_dsexist macro with different types of inputs (null, existing, non-existent datasets, in SASHELP, etc.) to verify that the returned result is correct. Results are displayed in the SAS log via %PUT.
Explanation : Last step of the validation flow (commented out). This call to an (unprovided) %_delete macro is intended to clean up the test environment by deleting the 'pwd.test2' dataset created previously.
Copied!
%_delete(data=pwd.test2);
*/
1
%_delete(DATA=pwd.test2);
2
3
*/
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.
Copyright Info : Copyright (c) 2001-2025 Rodney Sparapani
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.