Macros for SAS Application Developers
https://github.com/sasjs/core
mp_ds2cards.test.sas
Go to the documentation of this file.
1 /**
2  @file
3  @brief Testing mp_ds2cards.sas macro
4 
5  <h4> SAS Macros </h4>
6  @li mp_ds2cards.sas
7  @li mp_assert.sas
8 
9 **/
10 
11 /**
12  * test 1 - rebuild an existing dataset
13  * Cars is a great dataset - it contains leading spaces, and formatted numerics
14  */
15 
16 %mp_ds2cards(base_ds=sashelp.cars
17  , tgt_ds=work.test
18  , cards_file= "%sysfunc(pathname(work))/cars.sas"
19  , showlog=NO
20 )
21 %inc "%sysfunc(pathname(work))/cars.sas"/source2 lrecl=32767;
22 
23 proc compare base=sashelp.cars compare=work.test;
24 quit;
25 
26 %mp_assert(
27  iftrue=(&sysinfo=1),
28  desc=sashelp.cars is identical except for ds label,
29  outds=work.test_results
30 )
31 
32 /**
33  * test 2 - binary data compare
34  */
35 data work.binarybase;
36  format bin $hex500. z $hex.;
37  do x=1 to 250;
38  z=byte(x);
39  bin=trim(bin)!!z;
40  output;
41  end;
42 run;
43 
44 %mp_ds2cards(base_ds=work.binarybase
45  , showlog=YES
46  , cards_file="%sysfunc(pathname(work))/c2.sas"
47  , tgt_ds=work.binarycompare
48  , append=
49 )
50 
51 %inc "%sysfunc(pathname(work))/c2.sas"/source2 lrecl=32767;
52 
53 proc compare base=work.binarybase compare=work.binarycompare;
54 run;
55 
56 %mp_assert(
57  iftrue=(&sysinfo=0),
58  desc=work.binarybase dataset is identical,
59  outds=work.test_results
60 )