Loading...
Searching...
No Matches
getdata.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief testing gethistory service
4
5 <h4> SAS Macros </h4>
6 @li mp_assertcols.sas
7 @li mp_assertcolvals.sas
8 @li mp_assertdsobs.sas
9 @li mf_getuniquefileref.sas
10 @li mf_getuniquename.sas
11 @li mp_filterstore.sas
12 @li mx_testservice.sas
13
14**/
15
16%let _program=&appLoc/services/editors/getdata;
17
18/**
19 * Test 1 - basic fetch
20 */
21
22%let f1=%mf_getuniquefileref();
23data _null_;
24 file &f1 termstr=crlf;
25 put 'LIBDS:$43.';
26 put "&dclib..MPE_TABLES";
27run;
28%mx_testservice(&_program,
29 viyacontext=&defaultcontext,
30 inputfiles=&f1:sascontroltable,
31 outlib=web1,
32 mdebug=&sasjs_mdebug
33)
34data _null_;
35 infile "%sysfunc(pathname(WEB1))" lrecl=32767;
36 input;
37 putlog _infile_;
38run;
39
40data sasdata;
41 set web1.sasdata;
42data sasparams;
43 set web1.sasparams;
44data approvers;
45 set web1.approvers;
46data dqrules;
47 set web1.dqrules;
48data dqdata;
49 set web1.dqdata;
50data cols;
51 set web1.cols;
52data maxvarlengths;
53 set web1.maxvarlengths;
54data xl_rules;
55 set web1.xl_rules;
56data query;
57 set web1.query;
58run;
59
60%mp_assertcols(work.query,
61 desc=Query dataset is empty (test cols not obs as table has one row),
62 cols=VARIABLE_NM RAW_VALUE SUBGROUP_ID,
63 test=NONE,
64 outds=work.test_results
65)
66%mp_assertdsobs(work.sasdata,
67 desc=Test1 - data is returned,
68 test=HASOBS,
69 outds=work.test_results
70)
71
72
73/**
74 * Test 2 - filtered view
75 */
76
77/* first, make filter */
78data work.inquery;
79 infile datalines4 dsd;
80 input GROUP_LOGIC:$3. SUBGROUP_LOGIC:$3. SUBGROUP_ID:8. VARIABLE_NM:$32.
81 OPERATOR_NM:$10. RAW_VALUE:$4000.;
82datalines4;
83AND,AND,1,LIBREF,CONTAINS,"'DC'"
84AND,OR,2,DSN,=,"'MPE_LOCK_ANYTABLE'"
85;;;;
86run;
87%mp_filterstore(
88 libds=&dc_libref..MPE_TABLES,
89 filter_summary=&dc_libref..mpe_filteranytable,
90 filter_detail=&dc_libref..mpe_filtersource,
91 lock_table=&dc_libref..mpe_lockanytable,
92 maxkeytable=&dc_libref..mpe_maxkeyvalues,
93 queryds=work.inquery,
94 outresult=work.result,
95 outquery=work.query
96)
97data _null_;
98 set work.result;
99 call symputx('filter_rk',filter_rk);
100run;
101
102%let f2=%mf_getuniquefileref();
103data _null_;
104 file &f2 termstr=crlf;
105 put 'LIBDS:$43. FILTER_RK:8.';
106 put "&dclib..MPE_TABLES,&filter_rk";
107run;
108
109%mx_testservice(&_program,
110 viyacontext=&defaultcontext,
111 inputfiles=&f2:sascontroltable,
112 outlib=web2
113)
114
115data sasdata;
116 set web2.sasdata;
117data query;
118 set web2.query;
119run;
120
121%mp_assertdsobs(work.query,
122 desc=Test2 - query has rows,
123 test=HASOBS,
124 outds=work.test_results
125)
126%mp_assertdsobs(work.sasdata,
127 desc=Test2 - data has just one row,
128 test=EQUALS 1,
129 outds=work.test_results
130)
131
132
133/**
134 * Test 3 - format catalog
135 */
136
137/* first, make sure format data exists */
138%let fmtname=%upcase(%substr(%mf_getuniquename(prefix=FMT),1,15))NAME;
139
140/* add formats */
141data work.fmts;
142 length fmtname $32;
143 fmtname="&fmtname";
144 type='N';
145 do start=1 to 10;
146 label= cats("&fmtname",start);
147 end=start;
148 output;
149 end;
150run;
151proc sort data=work.fmts nodupkey;
152 by fmtname type start;
153run;
154proc format cntlin=work.fmts library=dctest.dcfmts;
155run;
156
157/* now, make filter */
158data work.inquery3;
159 infile datalines4 dsd;
160 input GROUP_LOGIC:$3. SUBGROUP_LOGIC:$3. SUBGROUP_ID:8. VARIABLE_NM:$32.
161 OPERATOR_NM:$10. RAW_VALUE:$4000.;
162 RAW_VALUE="'&fmtname'";
163datalines4;
164AND,AND,1,FMTNAME,CONTAINS,placeholder (see line above)
165;;;;
166run;
167%mp_filterstore(
168 libds=DCTEST.DCFMTS-FC,
169 filter_summary=&dc_libref..mpe_filteranytable,
170 filter_detail=&dc_libref..mpe_filtersource,
171 lock_table=&dc_libref..mpe_lockanytable,
172 maxkeytable=&dc_libref..mpe_maxkeyvalues,
173 queryds=work.inquery3,
174 outresult=work.result3,
175 outquery=work.query
176)
177data _null_;
178 set work.result3;
179 call symputx('filter_rk3',filter_rk);
180run;
181
182%let f3=%mf_getuniquefileref();
183data _null_;
184 file &f3 termstr=crlf;
185 put 'LIBDS:$43. FILTER_RK:8.';
186 put "DCTEST.DCFMTS-FC,&filter_rk3";
187run;
188
189%mx_testservice(&_program,
190 viyacontext=&defaultcontext,
191 inputfiles=&f3:sascontroltable,
192 outlib=web3,
193 mdebug=&sasjs_mdebug
194)
195
196data sasdata3;
197 set web3.sasdata;
198 putlog (_all_)(=);
199data query3;
200 set web3.query;
201run;
202
203%mp_assertdsobs(work.query3,
204 desc=Test3 - format query has rows,
205 test=HASOBS,
206 outds=work.test_results
207)
208%mp_assertdsobs(work.sasdata3,
209 desc=Test3 - format data has rows,
210 test=EQUALS 10,
211 outds=work.test_results
212)