Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mf_getfmtname.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Extracts a format name from a fully defined format
4 @details Converts formats in like $thi3. and th13.2 $THI and TH.
5 Usage:
6
7 %put %mf_getfmtname(8.);
8 %put %mf_getfmtname($4.);
9 %put %mf_getfmtname(comma14.10);
10
11 Returns:
12
13 > W
14 > $CHAR
15 > COMMA
16
17 Note that system defaults are inferred from the values provided.
18
19 @param [in] fmt The fully defined format. If left blank, nothing is returned.
20
21 @returns The name (without width or decimal) of the format.
22
23 @version 9.2
24 @author Allan Bowe
25
26**/
27
28%macro mf_getfmtname(fmt
29)/*/STORE SOURCE*/ /minoperator mindelimiter=' ';
30
31%local out dsid nvars x rc fmt;
32
33/* extract actual format name from the format definition */
34%let fmt=%scan(&fmt,1,.);
35%do %while(%substr(&fmt,%length(&fmt),1) in 1 2 3 4 5 6 7 8 9 0);
36 %if %length(&fmt)=1 %then %let fmt=W;
37 %else %let fmt=%substr(&fmt,1,%length(&fmt)-1);
38%end;
39
40%if &fmt=$ %then %let fmt=$CHAR;
41
42/* send them out without spaces or quote markers */
43%do;%unquote(%upcase(&fmt))%end;
44%mend mf_getfmtname;