Macros for SAS Application Developers
https://github.com/sasjs/core
mp_jsonout.test.2.sas
Go to the documentation of this file.
1 /**
2  @file
3  @brief Testing mp_jsonout.sas macro with special missings
4 
5  <h4> SAS Macros </h4>
6  @li mp_jsonout.sas
7  @li mp_assert.sas
8 
9 **/
10 
11 filename webref temp;
12 
13 data demo;
14  do x=._,.,.a,.b,.c,.d,.e,-99, 0, 1,2, 3.333333;
15  output;
16  end;
17 run;
18 %mp_jsonout(OPEN,jref=webref)
19 %mp_jsonout(OBJ,demo,jref=webref,fmt=N,missing=STRING)
20 %mp_jsonout(CLOSE,jref=webref)
21 
22 data _null_;
23  infile webref;
24  input;
25  putlog _infile_;
26 run;
27 
28 libname web JSON fileref=webref;
29 
30 /* proc json turns to char - so switch back to numeric */
31 data work.test(keep=x);
32  set web.demo(rename=(x=y));
33  if y ='_' then x=._;
34  else if anyalpha(y) then x=input(cats(".",y),best.);
35  else x=input(y,best.);
36  put (_all_)(=);
37 run;
38 
39 %mp_assert(
40  iftrue=(&syscc=0),
41  desc=Checking for error condition with special missing export,
42  outds=work.test_results
43 )
44 
45 proc compare base=work.demo compare=work.test;
46 quit;
47 
48 %mp_assert(
49  iftrue=(&sysinfo=0),
50  desc=Returned json is identical to input table for all special missings,
51  outds=work.test_results
52 )