Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mp_sortinplace.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing mp_sortinplace.test.sas
4
5 <h4> SAS Macros </h4>
6 @li mp_sortinplace.sas
7 @li mp_assert.sas
8 @li mp_assertdsobs.sas
9 @li mp_getconstraints.sas
10
11**/
12
13
14/** Test 1 - regular usage */
15proc sql;
16create table work.example as
17 select * from sashelp.classfit;
18alter table work.example
19 add constraint pk primary key(name);
20%mp_sortinplace(work.example)
21
22%mp_getconstraints(lib=work,ds=example,outds=work.testme)
23
24%mp_assertdsobs(work.testme,
25 desc=Test1 - check constraints recreated,
26 test=EQUALS 1,
27 outds=work.test_results
28)
29
30%let test1=0;
31data _null_;
32 set work.example;
33 call symputx('test1',name);
34 stop;
35run;
36%mp_assert(
37 iftrue=(
38 %str(&test1)=%str(Alfred)
39 ),
40 desc=Check if sort was appplied,
41 outds=work.test_results
42)
43
44/** Test 2 - table without PK */
45proc sql;
46create table work.example2 as
47 select * from sashelp.classfit;
48%mp_sortinplace(work.example2)
49%mp_assert(
50 iftrue=(
51 %str(&syscc)=%str(0)
52 ),
53 desc=Ensure no errors when no key exists,
54 outds=work.test_results
55)
56
57%let test2=0;
58data _null_;
59 set work.example2;
60 call symputx('test2',name);
61 stop;
62run;
63%mp_assert(
64 iftrue=(
65 %str(&test2)=%str(Alfred)
66 ),
67 desc=Check if sort was appplied when no index exists,
68 outds=work.test_results
69)