This program executes a series of unit tests to ensure that the `%mp_makedata` macro functions correctly. It creates tables with specific constraints (primary keys, non-null values) via `PROC SQL`, populates these tables using the macro, then uses `%mp_assert` and `DATA _NULL_` steps to check the number of observations, data integrity (string length), and error handling.
Data Analysis
Type : INTERNAL_CREATION
Data is dynamically generated by the `%mp_makedata` macro based on the structure of the tables defined in the script (work.example, work.example2).
1 Code Block
PROC SQL Data
Explanation : Definition of the test table `work.example` structure with integrity constraints, followed by the generation of 500 test observations via `%mp_makedata`.
Explanation : Verification via `%mp_assert` that the number of observations in the created table is exactly 500, using the utility macro `%mf_nobs`.
Copied!
%mp_assert(
iftrue=("%mf_nobs(work.example)"="500"),
desc=Check that 500 rows were created,
outds=work.test_results
)
1
%mp_assert(
2
iftrue=("%mf_nobs(work.example)"="500"),
3
desc=Check that 500 rows were created,
4
outds=work.test_results
5
)
3 Code Block
DATA STEP
Explanation : Technical Data Step to retrieve the length of the `dd_source` variable from the first observation and store it in the macro variable `lenvar` for later assertion.
Copied!
data _null_;
set work.example;
call symputx('lenvar',length(dd_source));
stop;
run;
1
DATA _null_;
2
SET work.example;
3
call symputx('lenvar',LENGTH(dd_source));
4
stop;
5
RUN;
4 Code Block
MACRO CALL
Explanation : Assertion checking that the `dd_source` variable has been populated to its full declared length (2048 characters).
Copied!
%mp_assert(
iftrue=("&lenvar"="2048"),
desc=Check that entire length of variable is populated,
outds=work.test_results
)
1
%mp_assert(
2
iftrue=("&lenvar"="2048"),
3
desc=Check that entire LENGTH of variable is populated,
4
outds=work.test_results
5
)
5 Code Block
PROC SQL Data
Explanation : Creation of a second table `work.example2` without primary key constraints to test the default behavior of data generation.
Explanation : Final verification that the execution proceeded without system errors (`&syscc=0`) for the table without keys.
Copied!
%mp_assert(
iftrue=(&syscc=0),
desc=Ensure tables without keys still generate,
outds=work.test_results
)
1
%mp_assert(
2
iftrue=(&syscc=0),
3
desc=Ensure tables without keys still generate,
4
outds=work.test_results
5
)
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.