-
Notifications
You must be signed in to change notification settings - Fork 8
/
viewformat.sas
76 lines (63 loc) · 2.67 KB
/
viewformat.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
%macro ViewFormat(library,format,keep=start end label type,open=Y) / des="Open a format for viewing";
/********************************************************************************
BEGIN MACRO HEADER
********************************************************************************
Name: ViewFormat
Author: Chris Swenson
Created: 2010-09-29
Purpose: Open a format for viewing
Arguments: library - library that the format is in
format - name of format
keep= - variables to keep, defaulted to START, END, LABEL, and
TYPE
open= - Y/N flag to indicate whether to open the table at the
end, defaulted to Y
Revisions
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Date Author Comments
¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯
YYYY-MM-DD III Please use this format and insert new entries above
********************************************************************************
END MACRO HEADER
********************************************************************************/
%if "&library"="" %then %do;
%put %str(E)RROR: No LIBRARY argument specified.;
%return;
%end;
%if %sysfunc(libref(&library)) ne 0 %then %do;
%put %str(E)RROR: The specified library does not exist.;
%return;
%end;
%if "&format"="" %then %do;
%put %str(E)RROR: No FORMAT argument specified.;
%return;
%end;
%if %eval( %sysfunc(cexist(&library..formats.&format..format)) + %sysfunc(cexist(&library..formats.&format..formatc)) )=0 %then %do;
%put %str(E)RROR: The specified format does not exist.;
%return;
%end;
/* Check for argument values in (Y N) */
%let OPEN=%substr(%upcase(&OPEN), 1, 1);
%if %index(*Y*N*,*&OPEN*)=0 %then %do;
%put %str(E)RROR: %str(I)nvalid argument specified for OPEN.;
%put %str(E)RROR- Please use one of the following: Y or N.;
%return;
%end;
proc format library=&library cntlout=&format
%if "&keep" ne "" %then %do;
(keep=&keep)
%end;
;
%if %sysfunc(cexist(&library..formats.&format..format))=1 %then %do;
select &format;
%end;
%else %if %sysfunc(cexist(&library..formats.&format..formatc)) %then %do;
select $&format;
%end;
run;
%if %sysfunc(exist(&format))=1
and &OPEN=Y
%then %do;
dm "vt %sysfunc(compress(&format))" vt;
%end;
%mend ViewFormat;