@sasjs/core 4.21.3 → 4.23.0
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.
- package/base/mf_fmtdttm.sas +42 -0
- package/base/mf_getuniquelibref.sas +5 -5
- package/base/mf_getvarcount.sas +22 -5
- package/base/mp_abort.sas +6 -1
- package/base/mp_getmaxvarlengths.sas +27 -3
- package/base/mp_lockanytable.sas +4 -3
- package/base/mp_retainedkey.sas +3 -2
- package/base/mp_storediffs.sas +3 -3
- package/package.json +1 -1
- package/server/ms_createwebservice.sas +5 -0
- package/server/ms_webout.sas +5 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
@file
|
|
3
|
+
@brief Returns E8601DT26.6 if compatible else DATETIME19.3
|
|
4
|
+
@details From our experience in [Data Controller for SAS]
|
|
5
|
+
(https://datacontroller.io) deployments, the E8601DT26.6 datetime format has
|
|
6
|
+
the widest support when it comes to pass-through SQL queries.
|
|
7
|
+
|
|
8
|
+
However, it is not supported in WPS or early versions of SAS 9 (M3 and below)
|
|
9
|
+
when used as a datetime literal, eg:
|
|
10
|
+
|
|
11
|
+
data _null_;
|
|
12
|
+
demo="%sysfunc(datetime(),E8601DT26.6)"dt;
|
|
13
|
+
demo=;
|
|
14
|
+
run;
|
|
15
|
+
|
|
16
|
+
This macro will therefore return DATEITME19.3 as an alternative format
|
|
17
|
+
based on the runtime environment so that it can be used in such cases, eg:
|
|
18
|
+
|
|
19
|
+
data _null_;
|
|
20
|
+
demo="%sysfunc(datetime(),%mf_fmtdttm())"dt;
|
|
21
|
+
demo=;
|
|
22
|
+
run;
|
|
23
|
+
|
|
24
|
+
<h4> Related Macros </h4>
|
|
25
|
+
@li mf_fmtdttm.test.sas
|
|
26
|
+
|
|
27
|
+
@author Allan Bowe
|
|
28
|
+
**/
|
|
29
|
+
|
|
30
|
+
%macro mf_fmtdttm(
|
|
31
|
+
)/*/STORE SOURCE*/;
|
|
32
|
+
|
|
33
|
+
%if "&sysver"="9.2" or "&sysver"="9.3"
|
|
34
|
+
or ("&sysver"="9.4" and "%substr(&SYSVLONG,9,1)" le "3")
|
|
35
|
+
or "%substr(&sysver,1,1)"="4"
|
|
36
|
+
or "%substr(&sysver,1,1)"="5"
|
|
37
|
+
%then %do;DATETIME19.3%end;
|
|
38
|
+
%else %do;E8601DT26.6%end;
|
|
39
|
+
|
|
40
|
+
%mend mf_fmtdttm;
|
|
41
|
+
|
|
42
|
+
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
@brief Returns an unused libref
|
|
4
4
|
@details Use as follows:
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
libname mclib0 (work);
|
|
7
|
+
libname mclib1 (work);
|
|
8
|
+
libname mclib2 (work);
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
%let libref=%mf_getuniquelibref();
|
|
11
|
+
%put &=libref;
|
|
12
12
|
|
|
13
13
|
which returns:
|
|
14
14
|
|
package/base/mf_getvarcount.sas
CHANGED
|
@@ -2,31 +2,48 @@
|
|
|
2
2
|
@file
|
|
3
3
|
@brief Returns number of variables in a dataset
|
|
4
4
|
@details Useful to identify those renagade datasets that have no columns!
|
|
5
|
+
Can also be used to count for numeric, or character columns
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
%put Number of Variables=%mf_getvarcount(sashelp.class);
|
|
8
|
+
%put Character Variables=%mf_getvarcount(sashelp.class,typefilter=C);
|
|
9
|
+
%put Numeric Variables = %mf_getvarcount(sashelp.class,typefilter=N);
|
|
7
10
|
|
|
8
11
|
returns:
|
|
9
12
|
> Number of Variables=4
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
|
|
15
|
+
@param [in] libds Two part dataset (or view) reference.
|
|
16
|
+
@param [in] typefilter= (A) Filter for certain types of column. Valid values:
|
|
17
|
+
@li A Count All columns
|
|
18
|
+
@li C Count Character columns only
|
|
19
|
+
@li N Count Numeric columns only
|
|
12
20
|
|
|
13
21
|
@version 9.2
|
|
14
22
|
@author Allan Bowe
|
|
15
23
|
|
|
16
24
|
**/
|
|
17
25
|
|
|
18
|
-
%macro mf_getvarcount(libds
|
|
26
|
+
%macro mf_getvarcount(libds,typefilter=A
|
|
19
27
|
)/*/STORE SOURCE*/;
|
|
20
|
-
%local dsid nvars rc ;
|
|
28
|
+
%local dsid nvars rc outcnt x;
|
|
21
29
|
%let dsid=%sysfunc(open(&libds));
|
|
22
30
|
%let nvars=.;
|
|
31
|
+
%let outcnt=0;
|
|
32
|
+
%let typefilter=%upcase(&typefilter);
|
|
23
33
|
%if &dsid %then %do;
|
|
24
34
|
%let nvars=%sysfunc(attrn(&dsid,NVARS));
|
|
35
|
+
%if &typefilter=A %then %let outcnt=&nvars;
|
|
36
|
+
%else %if &nvars>0 %then %do x=1 %to &nvars;
|
|
37
|
+
/* increment based on variable type */
|
|
38
|
+
%if %sysfunc(vartype(&dsid,&x))=&typefilter %then %do;
|
|
39
|
+
%let outcnt=%eval(&outcnt+1);
|
|
40
|
+
%end;
|
|
41
|
+
%end;
|
|
25
42
|
%let rc=%sysfunc(close(&dsid));
|
|
26
43
|
%end;
|
|
27
44
|
%else %do;
|
|
28
45
|
%put unable to open &libds (rc=&dsid);
|
|
29
46
|
%let rc=%sysfunc(close(&dsid));
|
|
30
47
|
%end;
|
|
31
|
-
&
|
|
48
|
+
&outcnt
|
|
32
49
|
%mend mf_getvarcount;
|
package/base/mp_abort.sas
CHANGED
|
@@ -89,7 +89,12 @@
|
|
|
89
89
|
or "&SYSPROCESSNAME "="Compute Server "
|
|
90
90
|
or &mode=INCLUDE
|
|
91
91
|
%then %do;
|
|
92
|
-
options obs=max replace
|
|
92
|
+
options obs=max replace mprint;
|
|
93
|
+
%if "%substr(&sysver,1,1)" ne "4" and "%substr(&sysver,1,1)" ne "5"
|
|
94
|
+
%then %do;
|
|
95
|
+
options nosyntaxcheck;
|
|
96
|
+
%end;
|
|
97
|
+
|
|
93
98
|
%if &mode=INCLUDE %then %do;
|
|
94
99
|
%if %sysfunc(exist(&errds))=1 %then %do;
|
|
95
100
|
data _null_;
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
<h4> SAS Macros </h4>
|
|
42
42
|
@li mcf_length.sas
|
|
43
43
|
@li mf_getuniquename.sas
|
|
44
|
+
@li mf_getvarcount.sas
|
|
44
45
|
@li mf_getvarlist.sas
|
|
45
46
|
@li mf_getvartype.sas
|
|
46
47
|
@li mf_getvarformat.sas
|
|
@@ -60,7 +61,7 @@
|
|
|
60
61
|
,outds=work.mp_getmaxvarlengths
|
|
61
62
|
)/*/STORE SOURCE*/;
|
|
62
63
|
|
|
63
|
-
%local vars prefix x var fmt;
|
|
64
|
+
%local vars prefix x var fmt srcds;
|
|
64
65
|
%let vars=%mf_getvarlist(libds=&libds);
|
|
65
66
|
%let prefix=%substr(%mf_getuniquename(),1,25);
|
|
66
67
|
%let num2char=%upcase(&num2char);
|
|
@@ -70,6 +71,24 @@
|
|
|
70
71
|
%mcf_length(wrap=YES, insert_cmplib=YES)
|
|
71
72
|
%end;
|
|
72
73
|
|
|
74
|
+
%if &num2char=NO
|
|
75
|
+
and ("%substr(&sysver,1,1)"="4" or "%substr(&sysver,1,1)"="5")
|
|
76
|
+
and %mf_getvarcount(&libds,typefilter=N) gt 0
|
|
77
|
+
%then %do;
|
|
78
|
+
/* custom functions not supported in summary operations */
|
|
79
|
+
%let srcds=%mf_getuniquename();
|
|
80
|
+
data &srcds/view=&srcds;
|
|
81
|
+
set &libds;
|
|
82
|
+
%do x=1 %to %sysfunc(countw(&vars,%str( )));
|
|
83
|
+
%let var=%scan(&vars,&x);
|
|
84
|
+
%if %mf_getvartype(&libds,&var)=N %then %do;
|
|
85
|
+
&prefix.&x=mcf_length(&var);
|
|
86
|
+
%end;
|
|
87
|
+
%end;
|
|
88
|
+
run;
|
|
89
|
+
%end;
|
|
90
|
+
%else %let srcds=&libds;
|
|
91
|
+
|
|
73
92
|
proc sql;
|
|
74
93
|
create table &outds (rename=(
|
|
75
94
|
%do x=1 %to %sysfunc(countw(&vars,%str( )));
|
|
@@ -94,10 +113,15 @@ create table &outds (rename=(
|
|
|
94
113
|
%end;
|
|
95
114
|
%end;
|
|
96
115
|
%else %do;
|
|
97
|
-
|
|
116
|
+
%if "%substr(&sysver,1,1)"="4" or "%substr(&sysver,1,1)"="5" %then %do;
|
|
117
|
+
max(&prefix.&x) as &prefix.&x
|
|
118
|
+
%end;
|
|
119
|
+
%else %do;
|
|
120
|
+
max(mcf_length(&var)) as &prefix.&x
|
|
121
|
+
%end;
|
|
98
122
|
%end;
|
|
99
123
|
%end;
|
|
100
|
-
from &
|
|
124
|
+
from &srcds;
|
|
101
125
|
|
|
102
126
|
proc transpose data=&outds
|
|
103
127
|
out=&outds(rename=(_name_=NAME COL1=MAXLEN));
|
package/base/mp_lockanytable.sas
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
@param [in] loop_secs= (1) Seconds to wait between each lock attempt
|
|
23
23
|
|
|
24
24
|
<h4> SAS Macros </h4>
|
|
25
|
+
@li mf_fmtdttm.sas
|
|
25
26
|
@li mp_abort.sas
|
|
26
27
|
@li mp_lockfilecheck.sas
|
|
27
28
|
@li mf_getuser.sas
|
|
@@ -111,7 +112,7 @@ run;
|
|
|
111
112
|
LOCK_LIB ="&lib";
|
|
112
113
|
LOCK_DS="&ds";
|
|
113
114
|
LOCK_STATUS_CD='LOCKED';
|
|
114
|
-
LOCK_START_DTTM="%sysfunc(datetime()
|
|
115
|
+
LOCK_START_DTTM="%sysfunc(datetime(),%mf_fmtdttm())"dt;
|
|
115
116
|
LOCK_USER_NM="&user";
|
|
116
117
|
LOCK_PID="&sysjobid";
|
|
117
118
|
LOCK_REF="&ref";
|
|
@@ -131,7 +132,7 @@ run;
|
|
|
131
132
|
proc sql;
|
|
132
133
|
update &ctl_ds
|
|
133
134
|
set LOCK_STATUS_CD='LOCKED'
|
|
134
|
-
, LOCK_START_DTTM="%sysfunc(datetime()
|
|
135
|
+
, LOCK_START_DTTM="%sysfunc(datetime(),%mf_fmtdttm())"dt
|
|
135
136
|
, LOCK_USER_NM="&user"
|
|
136
137
|
, LOCK_PID="&sysjobid"
|
|
137
138
|
, LOCK_REF="&ref"
|
|
@@ -206,7 +207,7 @@ run;
|
|
|
206
207
|
proc sql;
|
|
207
208
|
update &ctl_ds
|
|
208
209
|
set LOCK_STATUS_CD='UNLOCKED'
|
|
209
|
-
, LOCK_END_DTTM="%sysfunc(datetime()
|
|
210
|
+
, LOCK_END_DTTM="%sysfunc(datetime(),%mf_fmtdttm())"dt
|
|
210
211
|
, LOCK_USER_NM="&user"
|
|
211
212
|
, LOCK_PID="&sysjobid"
|
|
212
213
|
, LOCK_REF="&ref"
|
package/base/mp_retainedkey.sas
CHANGED
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
|
|
59
59
|
<h4> SAS Macros </h4>
|
|
60
60
|
@li mf_existvar.sas
|
|
61
|
+
@li mf_fmtdttm.sas
|
|
61
62
|
@li mf_getquotedstr.sas
|
|
62
63
|
@li mf_getuniquename.sas
|
|
63
64
|
@li mf_nobs.sas
|
|
@@ -217,12 +218,12 @@ quit;
|
|
|
217
218
|
set keytable="&base_libds"
|
|
218
219
|
,keycolumn="&retained_key"
|
|
219
220
|
,max_key=%eval(&maxkey+&newkey_cnt)
|
|
220
|
-
,processed_dttm="%sysfunc(datetime()
|
|
221
|
+
,processed_dttm="%sysfunc(datetime(),%mf_fmtdttm())"dt;
|
|
221
222
|
%end;
|
|
222
223
|
%else %do;
|
|
223
224
|
update &maxkeytable
|
|
224
225
|
set max_key=%eval(&maxkey+&newkey_cnt)
|
|
225
|
-
,processed_dttm="%sysfunc(datetime()
|
|
226
|
+
,processed_dttm="%sysfunc(datetime(),%mf_fmtdttm())"dt
|
|
226
227
|
where keytable="&base_libds";
|
|
227
228
|
%end;
|
|
228
229
|
%mp_lockanytable(UNLOCK
|
package/base/mp_storediffs.sas
CHANGED
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
data &ds1;
|
|
126
126
|
set &dslist indsname=&inds_auto;
|
|
127
127
|
&hashkey=put(md5(catx('|',%mf_getquotedstr(&key,quote=N))),$hex32.);
|
|
128
|
-
&inds_keep
|
|
128
|
+
&inds_keep=upcase(&inds_auto);
|
|
129
129
|
proc sort;
|
|
130
130
|
by &inds_keep &hashkey;
|
|
131
131
|
run;
|
|
@@ -160,8 +160,8 @@ data &ds4;
|
|
|
160
160
|
tgtvar_nm=upcase(tgtvar_nm);
|
|
161
161
|
if tgtvar_nm in (%upcase(&vlist));
|
|
162
162
|
|
|
163
|
-
if &inds_auto="&ds2" then tgtvar_type='N';
|
|
164
|
-
else if &inds_auto="&ds3" then tgtvar_type='C';
|
|
163
|
+
if upcase(&inds_auto)="&ds2" then tgtvar_type='N';
|
|
164
|
+
else if upcase(&inds_auto)="&ds3" then tgtvar_type='C';
|
|
165
165
|
else do;
|
|
166
166
|
putlog "%str(ERR)OR: unidentified vartype input!" &inds_auto;
|
|
167
167
|
call symputx('syscc',98);
|
package/package.json
CHANGED
|
@@ -390,6 +390,11 @@ data _null_;
|
|
|
390
390
|
put '%end; ';
|
|
391
391
|
put ' ';
|
|
392
392
|
put '%else %if &action=ARR or &action=OBJ %then %do; ';
|
|
393
|
+
put ' %if "%substr(&sysver,1,1)"="4" or "%substr(&sysver,1,1)"="5" %then %do; ';
|
|
394
|
+
put ' /* functions in formats unsupported */ ';
|
|
395
|
+
put ' %put &sysmacroname: forcing missing back to NULL as feature not supported; ';
|
|
396
|
+
put ' %let missing=NULL; ';
|
|
397
|
+
put ' %end; ';
|
|
393
398
|
put ' %mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt,jref=&fref ';
|
|
394
399
|
put ' ,engine=DATASTEP,missing=&missing,showmeta=&showmeta ';
|
|
395
400
|
put ' ) ';
|
package/server/ms_webout.sas
CHANGED
|
@@ -100,6 +100,11 @@
|
|
|
100
100
|
%end;
|
|
101
101
|
|
|
102
102
|
%else %if &action=ARR or &action=OBJ %then %do;
|
|
103
|
+
%if "%substr(&sysver,1,1)"="4" or "%substr(&sysver,1,1)"="5" %then %do;
|
|
104
|
+
/* functions in formats unsupported */
|
|
105
|
+
%put &sysmacroname: forcing missing back to NULL as feature not supported;
|
|
106
|
+
%let missing=NULL;
|
|
107
|
+
%end;
|
|
103
108
|
%mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt,jref=&fref
|
|
104
109
|
,engine=DATASTEP,missing=&missing,showmeta=&showmeta
|
|
105
110
|
)
|