Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mp_storediffs.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing mp_storediffs macro
4
5 <h4> SAS Macros </h4>
6 @li mp_storediffs.sas
7 @li mp_assert.sas
8 @li mp_assertcolvals.sas
9 @li mp_assertdsobs.sas
10
11**/
12
13/* make some data */
14
15data work.orig work.deleted work.changed work.appended;
16 set sashelp.class;
17 if _n_=1 then do;
18 output work.orig work.deleted;
19 end;
20 else if _n_=2 then do;
21 output work.orig;
22 age=99;
23 output work.changed;
24 end;
25 else do;
26 name='Newbie';
27 output work.appended;
28 stop;
29 end;
30run;
31
32%mp_storediffs(sashelp.class,work.orig,NAME
33 ,delds=work.deleted
34 ,modds=work.changed
35 ,appds=work.appended
36 ,outds=work.final
37 ,mdebug=1
38)
39
40%mp_assert(
41 iftrue=(
42 %str(&syscc)=%str(0)
43 ),
44 desc=ensure no errors,
45 outds=work.test_results
46)
47
48%mp_assertdsobs(work.final,
49 desc=Has 15 records,
50 test=EQUALS 15,
51 outds=work.test_results
52)
53
54data work.check;
55 length val $10;
56 do val='C','N';
57 output;
58 end;
59run;
60%mp_assertcolvals(work.final.tgtvar_type,
61 checkvals=work.check.val,
62 desc=All values have a match,
63 test=ALLVALS
64)
65
66/* Test for when there are no actual changes */
67data work.orig work.deleted work.changed work.appended;
68 set sashelp.class;
69 output work.orig;
70run;
71%mp_storediffs(sashelp.class,work.orig,NAME
72 ,delds=work.deleted
73 ,modds=work.changed
74 ,appds=work.appended
75 ,outds=work.final2
76 ,mdebug=1
77)
78%mp_assertdsobs(work.final2,
79 desc=No changes produces 0 records,
80 test=EQUALS 0,
81 outds=work.test_results
82)
83
84/* Test for deletes only */
85data work.orig work.deleted work.changed work.appended;
86 set sashelp.class;
87 output work.orig;
88 if _n_>5 then output work.deleted;
89run;
90
91%mp_storediffs(sashelp.class,work.orig,NAME
92 ,delds=work.deleted
93 ,modds=work.changed
94 ,appds=work.appended
95 ,outds=work.final3
96 ,mdebug=1
97)
98%mp_assertdsobs(work.final3,
99 desc=Delete has 70 records,
100 test=EQUALS 70,
101 outds=work.test_results
102)