Loading...
Searching...
No Matches
viewdata.test.1.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief testing public/viewdata service for filtered rowcount
4 @details We had a situation where the row count for a filtered view was
5 the count for the entire table, not the filtered view.
6
7 This test first makes a filter, then applies to to a table, and checks the
8 rowcount.
9
10 <h4> SAS Macros </h4>
11 @li mp_assert.sas
12 @li mp_testservice.sas
13 @li mf_getuniquefileref.sas
14
15**/
16
17/* first, ensure the table has the 3 records we need */
18proc sql;
19delete from &dclib..mpe_x_test where PRIMARY_KEY_FIELD in (1,2,3);
20data work.append;
21 set &dclib..mpe_x_test;
22 do PRIMARY_KEY_FIELD=1,2,3;
23 output;
24 end;
25 stop;
26run;
27proc append base=&dclib..mpe_x_test data=work.append;
28run;
29
30/* now, validate the filter and get the RK */
31%let _program=&appLoc/services/public/validatefilter;
32
33/* create filter */
34%let f1=%mf_getuniquefileref();
35data _null_;
36 file &f1 termstr=crlf;
37 put 'filter_table:$41.';
38 put "&dclib..MPE_X_TEST";
39run;
40%let f2=%mf_getuniquefileref();
41data _null_;
42 file &f2 termstr=crlf;
43 infile datalines4 dsd;
44 input;
45 put _infile_;
46datalines4;
47GROUP_LOGIC:$3. SUBGROUP_LOGIC:$3. SUBGROUP_ID:8. VARIABLE_NM:$32. OPERATOR_NM:$10. RAW_VALUE:$4000.
48AND,AND,1,PRIMARY_KEY_FIELD,IN,"(1,2,3)"
49;;;;
50run;
51%mp_testservice(&_program,
52 viyacontext=&defaultcontext,
53 inputfiles=&f1:iwant &f2:filterquery,
54 outlib=web1
55)
56data result;
57 set web1.result;
58 putlog (_all_)(=);
59 call symputx('filter_rk',filter_rk);
60run;
61
62
63/* now use this to filter a viewtable for three records */
64
65%let _program=&appLoc/services/public/viewdata;
66
67/* filter for one record */
68%let f3=%mf_getuniquefileref();
69data _null_;
70 file &f3 termstr=crlf;
71 put 'LIBDS:$char19. FILTER_RK:best.';
72 put "&dclib..MPE_X_TEST,&filter_rk";
73run;
74
75%mp_testservice(&_program,
76 viyacontext=&defaultcontext,
77 inputfiles=&f3:SASControlTable ,
78 outlib=web2,
79 outref=rawfile,
80 mdebug=1
81)
82%let nobs=0;
83data sasparams;
84 set web2.sasparams;
85 putlog (_all_)(=);
86 call symputx('nobs',nobs);
87run;
88
89%mp_assert(
90 iftrue=(&nobs=3),
91 desc=Checking the view table has 3 records returned,
92 outds=work.test_results
93)
94
95%put viewdata raw:;
96data _null_;
97 infile rawfile;
98 input;
99 putlog _infile_;
100run;
101
102