Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mf_getvarformat.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing mf_getvarformat macro
4
5 <h4> SAS Macros </h4>
6 @li mf_getvarformat.sas
7 @li mp_assert.sas
8 @li mp_assertscope.sas
9
10**/
11
12data work.varformat_test;
13 length str1 $1 num1 8 str2 $10 num2 8;
14 format str1 $1. num1 datetime19.;
15 str1='a';
16 num1=0;
17 str2='hello mum!';
18 num2=666;
19 output;
20run;
21
22%mp_assertscope(SNAPSHOT)
23%put scope check:%mf_getvarformat(work.varformat_test,str1);
24%mp_assertscope(COMPARE,
25 desc=Checking that mf_getvarformat does not leak scope,
26 outds=work.test_results
27)
28
29%mp_assert(
30 iftrue=(%mf_getvarformat(work.varformat_test,str1)=$1.),
31 desc=Checking the format of a character variable is returned,
32 outds=work.test_results
33)
34
35%mp_assert(
36 iftrue=(%mf_getvarformat(work.varformat_test,num1)=DATETIME19.),
37 desc=Checking the format of a numeric variable is returned,
38 outds=work.test_results
39)
40
41%mp_assert(
42 iftrue=(%mf_getvarformat(work.varformat_test,str2,force=1)=$10.),
43 desc=Checking force=1 supplies a character default of the variable length,
44 outds=work.test_results
45)
46
47%mp_assert(
48 iftrue=(%mf_getvarformat(work.varformat_test,num2,force=1)=best.),
49 desc=Checking force=1 supplies a numeric default of best.,
50 outds=work.test_results
51)
52
53%mp_assert(
54 iftrue=(%length(%mf_getvarformat(work.varformat_test,nosuchvar))=0),
55 desc=Checking a variable that does not exist returns nothing,
56 outds=work.test_results
57)
58
59%mp_assert(
60 iftrue=(%length(%mf_getvarformat(work.no_such_dataset,str1))=0),
61 desc=Checking a dataset that cannot be opened returns nothing,
62 outds=work.test_results
63)
64%let syscc=0;