Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mp_distinctfmtvalues.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing mp_distinctfmtvalues macro
4
5 <h4> SAS Macros </h4>
6 @li mp_distinctfmtvalues.sas
7 @li mp_assert.sas
8
9**/
10
11data work.fmtvals;
12 dt='01jan2020'd; output;
13 dt='01jan2020'd; output;
14 dt='02feb2021'd; output;
15 dt='03mar2022'd; output;
16 format dt date9.;
17run;
18
19%mp_distinctfmtvalues(libds=work.fmtvals,var=dt,outds=work.dfv_out)
20
21proc sql noprint;
22 select count(*) into: n_vals from work.dfv_out;
23 select count(*) into: n_hit from work.dfv_out
24 where formatted_value='01JAN2020';
25quit;
26
27%mp_assert(
28 iftrue=(&n_vals=3),
29 desc=Checking that duplicate formatted values collapse to one row,
30 outds=work.test_results
31)
32
33%mp_assert(
34 iftrue=(&n_hit=1),
35 desc=Checking that the value carries the variable format,
36 outds=work.test_results
37)