@sasjs/core 5.4.0 → 5.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,65 @@
1
+ /**
2
+ @file
3
+ @brief Returns the SAS format names that carry a date, datetime or time value
4
+
5
+ @details Prints a quoted, comma separated list of format NAMES, for use in
6
+ open code or in generated code:
7
+
8
+ if upcase(fmt) in (%mf_dttmfmts(DATE)) then fmttype='DATE';
9
+ else if upcase(fmt) in (%mf_dttmfmts(DATETIME)) then fmttype='DATETIME';
10
+ else if upcase(fmt) in (%mf_dttmfmts(TIME)) then fmttype='TIME';
11
+ else fmttype='NUM';
12
+
13
+ The names carry no width or decimal suffix, so strip that first (eg DATE9.
14
+ becomes DATE). This macro is the single source of truth for the lists -
15
+ mcf_getfmttype.sas builds its FCMP lookups from it.
16
+
17
+ @param [in] type DATE / DATETIME / TIME (case insensitive)
18
+
19
+ <h4> SAS Macros </h4>
20
+ @li mp_abort.sas
21
+
22
+ <h4> Related Macros </h4>
23
+ @li mcf_getfmttype.sas
24
+
25
+ @version 9.4
26
+ @author Allan Bowe
27
+ **/
28
+
29
+ %macro mf_dttmfmts(type);
30
+ %local type found;
31
+ %let type=%upcase(&type);
32
+ %let found=0;
33
+ /* so an empty type reaches the abort below, rather than an %eval error */
34
+ %if %length(&type)=0 %then %let type=INVALID;
35
+
36
+ %if &type=DATE %then %do;
37
+ %let found=1;
38
+ 'DATE','YYMMDD','B8601DA','DAY','DDMMYY','DDMMYYB','DDMMYYC','DDMMYYD',
39
+ 'DDMMYYN','DDMMYYP','DDMMYYS','DDMMYYx','DOWNAME','E8601DA','JULDAY',
40
+ 'JULIAN','MMDDYY','MMDDYYB','MMDDYYC','MMDDYYD','MMDDYYN','MMDDYYP',
41
+ 'MMDDYYS','MMDDYYx','MMYY','MMYYC','MMYYD','MMYYN','MMYYP','MMYYS','MMYYx',
42
+ 'MONNAME','MONTH','MONYY','PDJULG','PDJULI','QTR','QTRR','WEEKDATE',
43
+ 'WEEKDATX','WEEKDAY','WEEKU','WEEKV','WEEKW','WORDDATE','WORDDATX','YEAR',
44
+ 'YYMM','YYMMC','YYMMD','YYMMDDB','YYMMDDC','YYMMDDD','YYMMDDN','YYMMDDP',
45
+ 'YYMMDDS','YYMMDDx','YYMMN','YYMMP','YYMMS','YYMMx','YYMON','YYQ','YYQC',
46
+ 'YYQD','YYQN','YYQP','YYQR','YYQRC','YYQRD','YYQRN','YYQRP','YYQRS',
47
+ 'YYQRx','YYQS','YYQx','YYQZ','NLDATE'
48
+ %end;
49
+ %else %if &type=DATETIME %then %do;
50
+ %let found=1;
51
+ 'DATETIME','B8601DN','B8601DT','B8601DZ','DATEAMPM','DTDATE','DTMONYY',
52
+ 'DTWKDATX','DTYEAR','DTYYQC','E8601DN','E8601DT','E8601DZ','NLDATM'
53
+ %end;
54
+ %else %if &type=TIME %then %do;
55
+ %let found=1;
56
+ 'TIME','B8601LZ','B8601TM','B8601TZ','E8601LZ','E8601TM','E8601TZ','HHMM',
57
+ 'HOUR','MMSS','TIMEAMPM','TOD'
58
+ %end;
59
+
60
+ %mp_abort(iftrue=(&found=0)
61
+ ,mac=&sysmacroname
62
+ ,msg=%str(type must be DATE, DATETIME or TIME - got: &type)
63
+ )
64
+
65
+ %mend mf_dttmfmts;
package/base/mp_abort.sas CHANGED
@@ -66,7 +66,7 @@
66
66
  , mode=REGULAR
67
67
  )/*/STORE SOURCE*/;
68
68
 
69
- %global sysprocessmode sysprocessname sasjs_stpsrv_header_loc sasjsprocessmode;
69
+ %global sysprocessmode sysprocessname _sasjs_webout_headers sasjsprocessmode;
70
70
  %local fref fid i;
71
71
 
72
72
  %if not(%eval(%unquote(&iftrue))) %then %return;
@@ -171,7 +171,7 @@ and %superq(SYSPROCESSNAME) ne %str(Compute Server)
171
171
  name="_webout.json" lrecl=999999 mod;
172
172
  %end;
173
173
  %end;
174
- %else %if %sysfunc(filename(fref,&sasjs_stpsrv_header_loc))=0 %then %do;
174
+ %else %if %sysfunc(filename(fref,&_sasjs_webout_headers))=0 %then %do;
175
175
  options nobomfile;
176
176
  /* set up http header for SASjs Server */
177
177
  %let fid=%sysfunc(fopen(&fref,A));
@@ -6,7 +6,8 @@
6
6
 
7
7
  @li Blank labels are filled in with column names
8
8
  @li Formats are reconstructed with default values
9
- @li Types such as DATE / TIME / DATETIME are inferred from the formats
9
+ @li Types such as DATE / TIME / DATETIME are inferred from the formats,
10
+ using mf_dttmfmts.sas so every caller shares one set of format lists
10
11
 
11
12
  Example usage:
12
13
 
@@ -21,6 +22,9 @@
21
22
  |`REGION `|`3 `|`3 `|`REGION `|` `|`$3. `|`C `|`CHARACTER `|
22
23
 
23
24
 
25
+ <h4> SAS Macros </h4>
26
+ @li mf_dttmfmts.sas
27
+
24
28
  <h4> Related Macros </h4>
25
29
  @li mf_getvarlist.sas
26
30
  @li mm_getcols.sas
@@ -53,13 +57,9 @@ data &outds(keep=name type length varnum format label ddtype fmtname);
53
57
  else if formatd=0 then format=cats(fmtname,formatl,'.');
54
58
  else format=cats(fmtname,formatl,'.',formatd);
55
59
  type='N';
56
- if format=:'DATETIME' or format=:'E8601DT' or format=:'NLDATM'
57
- then ddtype='DATETIME';
58
- else if format=:'DATE' or format=:'DDMMYY' or format=:'MMDDYY'
59
- or format=:'YYMMDD' or format=:'E8601DA' or format=:'B8601DA'
60
- or format=:'MONYY' or format=:'NLDATE'
61
- then ddtype='DATE';
62
- else if format=:'TIME' then ddtype='TIME';
60
+ if upcase(fmtname) in (%mf_dttmfmts(DATETIME)) then ddtype='DATETIME';
61
+ else if upcase(fmtname) in (%mf_dttmfmts(DATE)) then ddtype='DATE';
62
+ else if upcase(fmtname) in (%mf_dttmfmts(TIME)) then ddtype='TIME';
63
63
  else ddtype='NUMERIC';
64
64
  end;
65
65
  if label='' then label=name;
@@ -3,7 +3,8 @@
3
3
  @brief Returns the type of the format
4
4
  @details
5
5
  Returns the type, eg DATE / DATETIME / TIME (based on hard-coded lookup)
6
- else CHAR / NUM.
6
+ else CHAR / NUM. The lookup lists live in mf_dttmfmts.sas, which is also
7
+ usable directly in open code.
7
8
 
8
9
  This macro may be extended in the future to support custom formats - this
9
10
  would necessitate a call to `dosubl()` for running a proc format with cntlout.
@@ -38,6 +39,7 @@
38
39
 
39
40
  <h4> SAS Macros </h4>
40
41
  @li mcf_init.sas
42
+ @li mf_dttmfmts.sas
41
43
 
42
44
  <h4> Related Programs </h4>
43
45
  @li mcf_getfmttype.test.sas
@@ -74,25 +76,10 @@ function mcf_getfmttype(fmtnm $) $8;
74
76
  else fmt=substr(fmt,1,length(fmt)-1);
75
77
  end;
76
78
 
77
- /* apply lookups */
78
- if cats(fmt) in ('DATETIME','B8601DN','B8601DN','B8601DT','B8601DT'
79
- ,'B8601DZ','B8601DZ','DATEAMPM','DTDATE','DTMONYY','DTWKDATX','DTYEAR'
80
- ,'DTYYQC','E8601DN','E8601DN','E8601DT','E8601DT','E8601DZ','E8601DZ'
81
- ,'NLDATM') then return('DATETIME');
82
- else if fmt in ('DATE','YYMMDD','B8601DA','B8601DA','DAY','DDMMYY'
83
- ,'DDMMYYB','DDMMYYC','DDMMYYD','DDMMYYN','DDMMYYP','DDMMYYS','DDMMYYx'
84
- ,'DOWNAME','E8601DA','E8601DA','JULDAY','JULIAN','MMDDYY','MMDDYYB'
85
- ,'MMDDYYC','MMDDYYD','MMDDYYN','MMDDYYP','MMDDYYS','MMDDYYx','MMYY'
86
- ,'MMYYC','MMYYD','MMYYN','MMYYP','MMYYS','MMYYx','MONNAME','MONTH'
87
- ,'MONYY','PDJULG','PDJULI','QTR','QTRR','WEEKDATE','WEEKDATX','WEEKDAY'
88
- ,'WEEKU','WEEKV','WEEKW','WORDDATE','WORDDATX','YEAR','YYMM','YYMMC'
89
- ,'YYMMD','YYMMDDB','YYMMDDC','YYMMDDD','YYMMDDN','YYMMDDP','YYMMDDS'
90
- ,'YYMMDDx','YYMMN','YYMMP','YYMMS','YYMMx','YYMON','YYQ','YYQC','YYQD'
91
- ,'YYQN','YYQP','YYQR','YYQRC','YYQRD','YYQRN','YYQRP','YYQRS','YYQRx'
92
- ,'YYQS','YYQx','YYQZ','NLDATE') then return('DATE');
93
- else if fmt in ('TIME','B8601LZ','B8601LZ','B8601TM','B8601TM','B8601TZ'
94
- ,'B8601TZ','E8601LZ','E8601LZ','E8601TM','E8601TM','E8601TZ','E8601TZ'
95
- ,'HHMM','HOUR','MMSS','TIMEAMPM','TOD') then return('TIME');
79
+ /* apply lookups - the format lists live in mf_dttmfmts.sas */
80
+ if cats(fmt) in (%mf_dttmfmts(DATETIME)) then return('DATETIME');
81
+ else if cats(fmt) in (%mf_dttmfmts(DATE)) then return('DATE');
82
+ else if cats(fmt) in (%mf_dttmfmts(TIME)) then return('TIME');
96
83
  else return('NUM');
97
84
  end;
98
85
  endsub;
package/package.json CHANGED
@@ -43,5 +43,5 @@
43
43
  "devDependencies": {
44
44
  "@nogoo9/gitleaks": "8.30.1-post.2"
45
45
  },
46
- "version": "5.4.0"
46
+ "version": "5.5.1"
47
47
  }
@@ -8,7 +8,7 @@
8
8
  the server.
9
9
 
10
10
  The location of this file is driven by the global variable
11
- `sasjs_stpsrv_header_loc` which is made available in the autoexec.
11
+ `_sasjs_webout_headers` which is made available in the autoexec.
12
12
 
13
13
  Usage:
14
14
 
@@ -28,11 +28,11 @@
28
28
  %macro mfs_httpheader(header_name
29
29
  ,header_value
30
30
  )/*/STORE SOURCE*/;
31
- %global sasjs_stpsrv_header_loc;
31
+ %global _sasjs_webout_headers;
32
32
  %local fref fid i;
33
33
 
34
- %if %sysfunc(filename(fref,&sasjs_stpsrv_header_loc)) ne 0 %then %do;
35
- %put &=fref &=sasjs_stpsrv_header_loc;
34
+ %if %sysfunc(filename(fref,&_sasjs_webout_headers)) ne 0 %then %do;
35
+ %put &=fref &=_sasjs_webout_headers;
36
36
  %put %str(ERR)OR: %sysfunc(sysmsg());
37
37
  %return;
38
38
  %end;
@@ -632,11 +632,11 @@ data _null_;
632
632
  put '%macro mfs_httpheader(header_name ';
633
633
  put ' ,header_value ';
634
634
  put ')/*/STORE SOURCE*/; ';
635
- put '%global sasjs_stpsrv_header_loc; ';
635
+ put '%global _sasjs_webout_headers; ';
636
636
  put '%local fref fid i; ';
637
637
  put ' ';
638
- put '%if %sysfunc(filename(fref,&sasjs_stpsrv_header_loc)) ne 0 %then %do; ';
639
- put ' %put &=fref &=sasjs_stpsrv_header_loc; ';
638
+ put '%if %sysfunc(filename(fref,&_sasjs_webout_headers)) ne 0 %then %do; ';
639
+ put ' %put &=fref &=_sasjs_webout_headers; ';
640
640
  put ' %put %str(ERR)OR: %sysfunc(sysmsg()); ';
641
641
  put ' %return; ';
642
642
  put '%end; ';