Published on :
Macro SASHELP

Unit test for the sas_set_index macro

This code is also available in: Deutsch Español Français
This program performs unit tests to verify the correct functioning of the %sas©_set_index macro. It tests the retrieval of index definitions on existing tables (sashelp.aarfm) and the absence of return on tables without indexes (sashelp.class), using assertions to validate the results.
Data Analysis

Type : SASHELP


Use of standard SASHELP demonstration tables (AARFM and CLASS) to ensure test portability.

1 Code Block
MACRO STATEMENT
Explanation :
Explicit declaration of the global macro variable 'indexx' used to capture test results.
Copied!
1%global indexx;
2 Code Block
MACRO CALL
Explanation :
Nominal case test with index: Variable initialization, macro call on table 'sashelp.aarfm'. The assertion verifies that the composite index 'locale key' is correctly identified.
Copied!
1%let indexx=
2%sas_set_index(sashelp.aarfm, indexx);
3%asserteq(locale key,&indexx.);
4 
3 Code Block
MACRO CALL
Explanation :
Test case without index: Variable reinitialization, macro call on table 'sashelp.class'. The assertion verifies that no index is returned (empty value expected).
Copied!
1%let indexx=
2%sas_set_index(sashelp.class, indexx);
3%asserteq(,&indexx.);
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.