Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
ms_webout.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing ms_webout macro
4
5 <h4> SAS Macros </h4>
6 @li mf_getuniquefileref.sas
7 @li ms_webout.sas
8 @li mp_assert.sas
9
10**/
11
12
13%let fref=%mf_getuniquefileref();
14%global _metaperson;
15data some datasets;
16 x=1;
17run;
18%ms_webout(OPEN,fref=&fref)
19%ms_webout(ARR,some,fref=&fref)
20%ms_webout(OBJ,datasets,fref=&fref)
21%ms_webout(CLOSE,fref=&fref)
22
23libname test JSON fileref=&fref;
24data root;
25 set test.root;
26 call symputx('checkval',sysvlong);
27run;
28data alldata;
29 set test.alldata;
30run;
31
32%mp_assert(
33 iftrue=(%str(&checkval)=%str(&sysvlong)),
34 desc=Check if the sysvlong value was created
35)
36
37/*
38 Test that ms_webout(FETCH) retains leading blanks in character values
39 (simulates the CSV format generated by the sasjs adapter, ie an input
40 statement in the first row followed by unquoted data)
41*/
42%let fref2=%mf_getuniquefileref();
43data _null_;
44 file &fref2 lrecl=32767 termstr=crlf;
45 put 'col1:$char10. col2:best.';
46 put ' padded,1';
47run;
48%global _webin_fileref _webin_name;
49%let _webin_fileref=&fref2;
50%let _webin_name=leadblank;
51%let _webin_file_count=1;
52%ms_webout(FETCH)
53
54data _null_;
55 set leadblank;
56 if col1=' padded' then call symputx('checkblank','PASS');
57 else call symputx('checkblank',cats('FAIL:',col1));
58run;
59
60%mp_assert(
61 iftrue=(&checkblank=PASS),
62 desc=ms_webout FETCH retains leading blanks with $char informat
63)
64
65/* same test, but with a plain $ informat (as sent by some clients) */
66%let fref3=%mf_getuniquefileref();
67data _null_;
68 file &fref3 lrecl=32767 termstr=crlf;
69 put 'col1:$10. col2:best.';
70 put ' padded,1';
71run;
72%let _webin_fileref=&fref3;
73%let _webin_name=leadblank2;
74%let _webin_file_count=1;
75%ms_webout(FETCH)
76
77data _null_;
78 set leadblank2;
79 if col1=' padded' then call symputx('checkblank2','PASS');
80 else call symputx('checkblank2',cats('FAIL:',col1));
81run;
82
83%mp_assert(
84 iftrue=(&checkblank2=PASS),
85 desc=ms_webout FETCH retains leading blanks with $ informat
86)