Macros for SAS Application Developers
https://github.com/sasjs/core
mp_getformats.test.sas
Go to the documentation of this file.
1 /**
2  @file
3  @brief Testing mp_getformats.sas macro
4 
5  <h4> SAS Macros </h4>
6  @li mf_mkdir.sas
7  @li mp_getformats.sas
8  @li mp_assert.sas
9 
10 **/
11 
12 /**
13  * Test - setup
14  */
15 
16 %mf_mkdir(&sasjswork/path1)
17 %mf_mkdir(&sasjswork/path2)
18 
19 libname path1 "&sasjswork/path1";
20 libname path2 "&sasjswork/path2";
21 
22 
23 PROC FORMAT library=path1;
24  value whichpath 0 = 'path1' other='big fat problem if not path1';
25 PROC FORMAT library=path2;
26  value whichpath 0 = 'path2' other='big fat problem if not path2';
27 RUN;
28 
29 
30 /** run with path1 path2 FMTSEARCH */
31 options insert=(fmtsearch=(path1 path2));
32 data _null_;
33  test=0;
34  call symputx('test1',put(test,whichpath.));
35 run;
36 %mp_assert(
37  iftrue=("&test1"="path1"),
38  desc=Check correct format is applied,
39  outds=work.test_results
40 )
41 %mp_getformats(fmtlist=WHICHPATH,outsummary=sum,outdetail=detail1)
42 %let tst1=0;
43 data _null_;
44  set detail1;
45  if fmtname='WHICHPATH' and start='**OTHER**' then call symputx('tst1',label);
46  putlog (_all_)(=);
47 run;
48 %mp_assert(
49  iftrue=("&tst1"="big fat problem if not path1"),
50  desc=Check correct detail results are applied,
51  outds=work.test_results
52 )
53 
54 /** run with path2 path1 FMTSEARCH */
55 options insert=(fmtsearch=(path2 path1));
56 data _null_;
57  test=0;
58  call symputx('test2',put(test,whichpath.));
59 run;
60 %mp_assert(
61  iftrue=("&test2"="path2"),
62  desc=Check correct format is applied,
63  outds=work.test_results
64 )
65 %mp_getformats(fmtlist=WHICHPATH,outsummary=sum,outdetail=detail2)
66 %let tst2=0;
67 data _null_;
68  set detail2;
69  if fmtname='WHICHPATH' and start='**OTHER**' then call symputx('tst2',label);
70  putlog (_all_)(=);
71 run;
72 %mp_assert(
73  iftrue=("&tst2"="big fat problem if not path2"),
74  desc=Check correct detail results are applied,
75  outds=work.test_results
76 )