@sasjs/core 3.7.0 → 3.7.4
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/mp_applyformats.sas +2 -2
- package/base/mp_filterstore.sas +49 -32
- package/base/mp_getcols.sas +18 -16
- package/package.json +2 -2
package/base/mp_applyformats.sas
CHANGED
|
@@ -142,16 +142,16 @@ run;
|
|
|
142
142
|
proc sql noprint;
|
|
143
143
|
select distinct lib into: liblist separated by ' ' from &inds;
|
|
144
144
|
%put &=liblist;
|
|
145
|
-
%do i=1 %to %sysfunc(countw(&liblist));
|
|
145
|
+
%if %length(&liblist)>0 %then %do i=1 %to %sysfunc(countw(&liblist));
|
|
146
146
|
%let lib=%scan(&liblist,1);
|
|
147
147
|
%let engine=%mf_getengine(&lib);
|
|
148
148
|
%if &engine ne V9 and &engine ne BASE %then %do;
|
|
149
149
|
%let msg=&lib has &engine engine - formats cannot be applied;
|
|
150
|
-
proc sql;
|
|
151
150
|
insert into &outds set lib="&lib",ds="_all_",var="_all", msg="&msg" ;
|
|
152
151
|
%if &errds=0 %then %put %str(ERR)OR: &msg;
|
|
153
152
|
%end;
|
|
154
153
|
%end;
|
|
154
|
+
quit;
|
|
155
155
|
|
|
156
156
|
%if %mf_nobs(&outds)>0 %then %return;
|
|
157
157
|
|
package/base/mp_filterstore.sas
CHANGED
|
@@ -121,46 +121,20 @@ run;
|
|
|
121
121
|
,mac=mp_filterstore
|
|
122
122
|
,msg=%str(syscc=&syscc after hash check)
|
|
123
123
|
)
|
|
124
|
-
%mp_abort(iftrue= ("&filter_hash"=" ")
|
|
124
|
+
%mp_abort(iftrue= ("&filter_hash "=" ")
|
|
125
125
|
,mac=mp_filterstore
|
|
126
126
|
,msg=%str(problem with filter_hash generation)
|
|
127
127
|
)
|
|
128
128
|
|
|
129
129
|
%if %mf_nobs(&outresult)=0 %then %do;
|
|
130
130
|
|
|
131
|
-
/* update
|
|
132
|
-
%let ds2=%mf_getuniquename(prefix=filterdetail);
|
|
133
|
-
data &ds2;
|
|
134
|
-
if 0 then set &filter_detail;
|
|
135
|
-
set &queryds;
|
|
136
|
-
format filter_hash $hex32. filter_line 8. processed_dttm E8601DT26.6;
|
|
137
|
-
filter_hash="&filter_hash";
|
|
138
|
-
filter_line=_n_;
|
|
139
|
-
PROCESSED_DTTM="%sysfunc(datetime(),E8601DT26.6)"dt;
|
|
140
|
-
run;
|
|
141
|
-
%mp_lockanytable(LOCK,
|
|
142
|
-
lib=%scan(&filter_detail,1,.)
|
|
143
|
-
,ds=%scan(&filter_detail,2,.)
|
|
144
|
-
,ref=MP_FILTERSTORE update - &filter_hash
|
|
145
|
-
,ctl_ds=&lock_table
|
|
146
|
-
)
|
|
147
|
-
proc append base=&filter_detail data=&ds2;
|
|
148
|
-
run;
|
|
149
|
-
|
|
150
|
-
%mp_lockanytable(UNLOCK,
|
|
151
|
-
lib=%scan(&filter_detail,1,.)
|
|
152
|
-
,ds=%scan(&filter_detail,2,.)
|
|
153
|
-
,ref=MP_FILTERSTORE update - &filter_hash
|
|
154
|
-
,ctl_ds=&lock_table
|
|
155
|
-
)
|
|
156
|
-
|
|
157
|
-
/* now update summary table */
|
|
131
|
+
/* first update summary table */
|
|
158
132
|
%let ds3=%mf_getuniquename(prefix=filtersum);
|
|
159
|
-
data
|
|
133
|
+
data work.&ds3;
|
|
160
134
|
if 0 then set &filter_summary;
|
|
161
135
|
filter_table=symget('libds');
|
|
162
136
|
filter_hash="&filter_hash";
|
|
163
|
-
PROCESSED_DTTM
|
|
137
|
+
PROCESSED_DTTM=%sysfunc(datetime());
|
|
164
138
|
output;
|
|
165
139
|
stop;
|
|
166
140
|
run;
|
|
@@ -168,7 +142,7 @@ run;
|
|
|
168
142
|
%mp_lockanytable(LOCK,
|
|
169
143
|
lib=%scan(&filter_summary,1,.)
|
|
170
144
|
,ds=%scan(&filter_summary,2,.)
|
|
171
|
-
,ref=MP_FILTERSTORE update - &filter_hash
|
|
145
|
+
,ref=MP_FILTERSTORE summary update - &filter_hash
|
|
172
146
|
,ctl_ds=&lock_table
|
|
173
147
|
)
|
|
174
148
|
|
|
@@ -190,21 +164,64 @@ run;
|
|
|
190
164
|
%mp_lockanytable(UNLOCK,
|
|
191
165
|
lib=%scan(&filter_summary,1,.)
|
|
192
166
|
,ds=%scan(&filter_summary,2,.)
|
|
193
|
-
,ref=MP_FILTERSTORE update - &filter_hash
|
|
167
|
+
,ref=MP_FILTERSTORE summary update - &filter_hash
|
|
194
168
|
,ctl_ds=&lock_table
|
|
195
169
|
)
|
|
196
170
|
|
|
171
|
+
%if &syscc ne 0 %then %do;
|
|
172
|
+
data _null_;
|
|
173
|
+
set &ds4;
|
|
174
|
+
putlog (_all_)(=);
|
|
175
|
+
run;
|
|
176
|
+
%goto err;
|
|
177
|
+
%end;
|
|
178
|
+
|
|
197
179
|
data &outresult;
|
|
198
180
|
set &filter_summary;
|
|
199
181
|
where filter_hash="&filter_hash";
|
|
200
182
|
run;
|
|
201
183
|
|
|
184
|
+
/* Next, update detail table */
|
|
185
|
+
%let ds2=%mf_getuniquename(prefix=filterdetail);
|
|
186
|
+
data &ds2;
|
|
187
|
+
if 0 then set &filter_detail;
|
|
188
|
+
set &queryds;
|
|
189
|
+
format filter_hash $hex32. filter_line 8.;
|
|
190
|
+
filter_hash="&filter_hash";
|
|
191
|
+
filter_line=_n_;
|
|
192
|
+
PROCESSED_DTTM=%sysfunc(datetime());
|
|
193
|
+
run;
|
|
194
|
+
%mp_lockanytable(LOCK,
|
|
195
|
+
lib=%scan(&filter_detail,1,.)
|
|
196
|
+
,ds=%scan(&filter_detail,2,.)
|
|
197
|
+
,ref=MP_FILTERSTORE update - &filter_hash
|
|
198
|
+
,ctl_ds=&lock_table
|
|
199
|
+
)
|
|
200
|
+
proc append base=&filter_detail data=&ds2;
|
|
201
|
+
run;
|
|
202
|
+
|
|
203
|
+
%mp_lockanytable(UNLOCK,
|
|
204
|
+
lib=%scan(&filter_detail,1,.)
|
|
205
|
+
,ds=%scan(&filter_detail,2,.)
|
|
206
|
+
,ref=MP_FILTERSTORE detail update &filter_hash
|
|
207
|
+
,ctl_ds=&lock_table
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
%if &syscc ne 0 %then %do;
|
|
211
|
+
data _null_;
|
|
212
|
+
set &ds2;
|
|
213
|
+
putlog (_all_)(=);
|
|
214
|
+
run;
|
|
215
|
+
%goto err;
|
|
216
|
+
%end;
|
|
217
|
+
|
|
202
218
|
%end;
|
|
203
219
|
|
|
204
220
|
proc sort data=&filter_detail(where=(filter_hash="&filter_hash")) out=&outquery;
|
|
205
221
|
by filter_line;
|
|
206
222
|
run;
|
|
207
223
|
|
|
224
|
+
%err:
|
|
208
225
|
%mp_abort(iftrue= (&syscc ne 0)
|
|
209
226
|
,mac=mp_filterstore
|
|
210
227
|
,msg=%str(syscc=&syscc on macro exit)
|
package/base/mp_getcols.sas
CHANGED
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
|
|
15
15
|
@param ds The dataset from which to obtain column metadata
|
|
16
16
|
@param outds= (work.cols) The output dataset to create. Sample data:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
|NAME:$32.|LENGTH:best.|VARNUM:best.|LABEL:$256.|FMTNAME:$32.|FORMAT:$49.|TYPE:$1.|DDTYPE:$9.|
|
|
18
|
+
|---|---|---|---|---|---|---|---|
|
|
19
|
+
|`AIR `|`8 `|`2 `|`international airline travel (thousands) `|` `|`8. `|`N `|`NUMERIC `|
|
|
20
|
+
|`DATE `|`8 `|`1 `|`DATE `|`MONYY `|`MONYY. `|`N `|`DATE `|
|
|
21
|
+
|`REGION `|`3 `|`3 `|`REGION `|` `|`$3. `|`C `|`CHARACTER `|
|
|
22
22
|
|
|
23
23
|
<h4> Related Macros </h4>
|
|
24
24
|
@li mf_getvarlist.sas
|
|
@@ -30,26 +30,27 @@
|
|
|
30
30
|
**/
|
|
31
31
|
|
|
32
32
|
%macro mp_getcols(ds, outds=work.cols);
|
|
33
|
-
|
|
33
|
+
%local dropds;
|
|
34
34
|
proc contents noprint data=&ds
|
|
35
35
|
out=_data_ (keep=name type length label varnum format:);
|
|
36
36
|
run;
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
%let dropds=&syslast;
|
|
38
|
+
data &outds(keep=name type length varnum format label ddtype fmtname);
|
|
39
|
+
set &dropds(rename=(format=fmtname type=type2));
|
|
39
40
|
name=upcase(name);
|
|
40
41
|
if type2=2 then do;
|
|
41
42
|
length format $49.;
|
|
42
|
-
if
|
|
43
|
-
else if formatl=0 then format=cats(
|
|
44
|
-
else format=cats(
|
|
43
|
+
if fmtname='' then format=cats('$',length,'.');
|
|
44
|
+
else if formatl=0 then format=cats(fmtname,'.');
|
|
45
|
+
else format=cats(fmtname,formatl,'.');
|
|
45
46
|
type='C';
|
|
46
47
|
ddtype='CHARACTER';
|
|
47
48
|
end;
|
|
48
49
|
else do;
|
|
49
|
-
if
|
|
50
|
-
else if formatl=0 then format=cats(
|
|
51
|
-
else if formatd=0 then format=cats(
|
|
52
|
-
else format=cats(
|
|
50
|
+
if fmtname='' then format=cats(length,'.');
|
|
51
|
+
else if formatl=0 then format=cats(fmtname,'.');
|
|
52
|
+
else if formatd=0 then format=cats(fmtname,formatl,'.');
|
|
53
|
+
else format=cats(fmtname,formatl,'.',formatd);
|
|
53
54
|
type='N';
|
|
54
55
|
if format=:'DATETIME' or format=:'E8601DT' then ddtype='DATETIME';
|
|
55
56
|
else if format=:'DATE' or format=:'DDMMYY' or format=:'MMDDYY'
|
|
@@ -61,5 +62,6 @@ data &outds(keep=name type length varnum format label ddtype);
|
|
|
61
62
|
end;
|
|
62
63
|
if label='' then label=name;
|
|
63
64
|
run;
|
|
64
|
-
|
|
65
|
+
proc sql;
|
|
66
|
+
drop table &dropds;
|
|
65
67
|
%mend mp_getcols;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sasjs/core",
|
|
3
|
-
"description": "
|
|
3
|
+
"description": "Macros for SAS Application Developers",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"SAS",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"ts-loader": "^9.2.6"
|
|
40
40
|
},
|
|
41
|
-
"version": "3.7.
|
|
41
|
+
"version": "3.7.4"
|
|
42
42
|
}
|