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 */
18 proc sql;
19 delete from &dclib..mpe_x_test where PRIMARY_KEY_FIELD in (1,2,3);
20 data work.append;
21  set &dclib..mpe_x_test;
22  do PRIMARY_KEY_FIELD=1,2,3;
23  output;
24  end;
25  stop;
26 run;
27 proc append base=&dclib..mpe_x_test data=work.append;
28 run;
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();
35 data _null_;
36  file &f1 termstr=crlf;
37  put 'filter_table:$41.';
38  put "&dclib..MPE_X_TEST";
39 run;
40 %let f2=%mf_getuniquefileref();
41 data _null_;
42  file &f2 termstr=crlf;
43  infile datalines4 dsd;
44  input;
45  put _infile_;
46 datalines4;
47 GROUP_LOGIC:$3. SUBGROUP_LOGIC:$3. SUBGROUP_ID:8. VARIABLE_NM:$32. OPERATOR_NM:$10. RAW_VALUE:$4000.
48 AND,AND,1,PRIMARY_KEY_FIELD,IN,"(1,2,3)"
49 ;;;;
50 run;
51 %mp_testservice(&_program,
52  viyacontext=&defaultcontext,
53  inputfiles=&f1:iwant &f2:filterquery,
54  outlib=web1
55 )
56 data result;
57  set web1.result;
58  putlog (_all_)(=);
59  call symputx('filter_rk',filter_rk);
60 run;
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();
69 data _null_;
70  file &f3 termstr=crlf;
71  put 'LIBDS:$char19. FILTER_RK:best.';
72  put "&dclib..MPE_X_TEST,&filter_rk";
73 run;
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;
83 data sasparams;
84  set web2.sasparams;
85  putlog (_all_)(=);
86  call symputx('nobs',nobs);
87 run;
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:;
96 data _null_;
97  infile rawfile;
98  input;
99  putlog _infile_;
100 run;
101 
102