Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mf_getvartype.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing mf_getvartype macro
4
5 <h4> SAS Macros </h4>
6 @li mf_getvartype.sas
7 @li mp_assert.sas
8 @li mp_assertscope.sas
9
10**/
11
12/* a zero length character variable cannot be built in SAS 9.4 - LENGTH
13 x $0 is rejected with "The length of a character variable must be in the
14 range of 1-32767" - so the shortest shape that can exist, a one byte blank,
15 is what distinguishes a blank return from a real type */
16data work.vartype_test;
17 length charvar $5 numvar 8 blankvar $1;
18 charvar='hello';
19 numvar=1;
20 blankvar='';
21 output;
22run;
23
24%mp_assertscope(SNAPSHOT)
25%put scope check:%mf_getvartype(work.vartype_test,charvar);
26%mp_assertscope(COMPARE,
27 desc=Checking that mf_getvartype does not leak scope,
28 outds=work.test_results
29)
30
31%mp_assert(
32 iftrue=(%mf_getvartype(work.vartype_test,charvar)=C),
33 desc=Checking a character variable returns C,
34 outds=work.test_results
35)
36
37%mp_assert(
38 iftrue=(%mf_getvartype(work.vartype_test,blankvar)=C),
39 desc=Checking a character variable holding only a blank still returns C,
40 outds=work.test_results
41)
42
43%mp_assert(
44 iftrue=(%mf_getvartype(work.vartype_test,numvar)=N),
45 desc=Checking a numeric variable returns N,
46 outds=work.test_results
47)
48
49%mp_assert(
50 iftrue=(%length(%mf_getvartype(work.vartype_test,nosuchvar))=1),
51 desc=Checking a variable that does not exist returns a blank,
52 outds=work.test_results
53)
54
55%mp_assert(
56 iftrue=(%length(%mf_getvartype(work.no_such_dataset,charvar))=0),
57 desc=Checking a dataset that cannot be opened returns nothing,
58 outds=work.test_results
59)
60%let syscc=0;