-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathifput.sas
60 lines (49 loc) · 2.27 KB
/
ifput.sas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
%macro IfPut(criteria,thenput,elseput,issue) / des="If/then execution for %PUT statement";
/********************************************************************************
BEGIN MACRO HEADER
********************************************************************************
Name: IfPut
Author: Chris Swenson
Created: 2010-02-15
Purpose: If/then execution for a %PUT statement
Arguments: criteria - criteria to fulfill to output note
thenput - note to output if criteria fulfilled
elseput - note to output if criteria not fulfilled
issue - type of issue to output the note in the THENPUT
argument as, either (E)RROR or (W)ARNING
Revisions
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Date Author Comments
¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯
YYYY-MM-DD III Please use this format and insert new entries above
********************************************************************************
END MACRO HEADER
********************************************************************************/
/* Check arguments */
%if %superq(criteria)=%str() %then %do;
%put %str(E)RROR: Missing criteria argument.;
%return;
%end;
%if %superq(thenput)=%str() %then %do;
%put %str(E)RROR: Missing thenput argument (message only).;
%return;
%end;
/* Determine issue type */
%if %superq(issue) ne %str() %then %do;
%let issue=%upcase(&issue);
%if &issue=E %then %let thenput=%str(E)RROR: &thenput;
%else %if &issue=W %then %let thenput=%str(W)ARNING: &thenput;
%else %do;
%put %str(E)RROR: %str(I)nvalid issue argument. Use E or W.;
%return;
%end;
%end;
/* Determine Type and Output */
%if %superq(elseput)=%str() %then %do;
%if %unquote(%superq(criteria)) %then %put %unquote(%superq(thenput));
%end;
%else %do;
%if %unquote(%superq(criteria)) %then %put %unquote(%superq(thenput));
%else %put %unquote(%superq(elseput));
%end;
%mend IfPut;