Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mp_jsonout.test.3.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing mp_jsonout.sas macro with non-standard chars
4
5 <h4> SAS Macros </h4>
6 @li mp_jsonout.sas
7 @li mp_assert.sas
8
9**/
10
11filename webref temp;
12
13data demo;
14 length x $100;
15 do x='"','0A'x,'0D'x,'09'x,'00'x,'0E'x,'0F'x,'01'x,'02'x,'10'x,'11'x,'\';
16 output;
17 end;
18 /* embedded quote variants */
19 x='say "hi" there'; output;
20 x='"fully quoted"'; output;
21 x='back\slash'; output;
22 x='quote and back\"slash'; output;
23 /* leading / trailing blank variants */
24 x=' leading blanks'; output;
25 x=' "leading blanks and quotes"'; output;
26 x='trailing blanks '; output;
27 x=' both '; output;
28run;
29%mp_jsonout(OPEN,jref=webref)
30%mp_jsonout(OBJ,demo,jref=webref)
31%mp_jsonout(CLOSE,jref=webref)
32
33data _null_;
34 infile webref;
35 input;
36 putlog _infile_;
37run;
38
39libname web JSON fileref=webref;
40
41%mp_assert(
42 iftrue=(&syscc=0),
43 desc=Checking for error condition with special chars export,
44 outds=work.test_results
45)
46
47/*
48data _null_;
49 set work.demo (in=start) web.demo (in=end);
50 put (_all_)(=);
51run;
52proc sql;
53describe table work.demo;
54describe table web.demo;
55*/
56
57proc compare base=work.demo compare=web.demo(keep=x);
58quit;
59
60/* sysinfo is a bitmask - keep only data-related bits, ie:
61 64 Base data set has observation not in comparison
62 128 Comparison data set has observation not in base
63 4096 A value comparison was unequal
64 32768 Number of observations differ
65 Attribute diffs (eg 16 - variable length) are ignored, as a JSON
66 round trip will not preserve lengths/formats/labels.
67*/
68/* SYSINFO is read only, so store the masked value in a new variable */
69%let sysinfo_masked=%sysfunc(band(&sysinfo, 64+128+4096+32768));
70
71%mp_assert(
72 iftrue=(&sysinfo_masked=0),
73 desc=Returned json is identical to input table for all special chars,
74 outds=work.test_results
75)