This macro, `assert_not_empty`, serves as an assertion routine. It first checks for the existence of the dataset passed via the `DS` parameter. If the dataset does not exist, or if it exists but contains no observations, an event is triggered by calling an external macro `%generate_event`. The details of this event (message, level, type, etc.) can be customized via parameters. If no custom message is provided, a default message is automatically generated to indicate the nature of the problem (non-existent or empty).
Data Analysis
Type : EXTERNAL
The macro is designed to operate on a dataset whose name is provided via the `DS` parameter, which is therefore external to the macro itself. Its operation also depends on the `%generate_event` macro, which is not defined in this script and must be available in the SAS environment.
1 Code Block
Macro
Explanation : This block defines the `assert_not_empty` macro. It uses the macro functions `%exist` to check if the dataset exists and `%obs` to count its observations. If the dataset is non-existent or empty, a local variable `EVENT_COUNT` is set to 1. In this case, the external macro `%generate_event` is called to signal the anomaly, passing the corresponding parameters to it. The global variable `futs_tst_cnt` is incremented, suggesting that this macro is part of a larger testing framework.
%IF &MESSAGE = %str() %THEN %let MESSAGE = DATASET &DS does not exist;
20
%END;
21
%ELSE %DO;
22
%IF %obs(&DS) eq 0 %THEN %DO;
23
%let EVENT_COUNT = 1;
24
%IF &MESSAGE = %str() %THEN
25
%let MESSAGE = DATASET &DS is empty;
26
%END;
27
%END;
28
29
%let futs_tst_cnt = %eval(&futs_tst_cnt.+1);
30
31
%IF &EVENT_COUNT gt 0 %THEN
32
%generate_event(TYPE=&TYPE, LEVEL=&LEVEL,
33
MESSAGE=&MESSAGE,
34
ATTACHDATA=&ATTACHDATA, ATTACHFILE=&ATTACHFILE,
35
METRIC=&METRIC,
36
PROPERTIES=&PROPERTIES,
37
ON_EVENT=&ON_EVENT,
38
DESCRIPTION=&DESCRIPTION, ABORT=&ABORT);
39
40
%mend assert_not_empty;
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) 2015 John Jacobs. All rights reserved.
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.