@sasjs/core 4.2.0 → 4.3.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.
@@ -131,7 +131,7 @@
131
131
  %put &sysmacroname: Switching to DATASTEP engine;
132
132
  %goto datastep;
133
133
  %end;
134
- data &tempds /view=&tempds;set &ds;
134
+ data &tempds;set &ds;
135
135
  %if &fmt=N %then format _numeric_ best32.;;
136
136
  /* PRETTY is necessary to avoid line truncation in large files */
137
137
  proc json out=&jref pretty
@@ -182,7 +182,7 @@
182
182
  %end;
183
183
  other = [best.];
184
184
 
185
- data &tempds/view=&tempds;
185
+ data &tempds;
186
186
  attrib _all_ label='';
187
187
  %do i=1 %to &numcols;
188
188
  %if &&typelong&i=char or &fmt=Y %then %do;
@@ -244,8 +244,7 @@
244
244
  %end;
245
245
 
246
246
  proc sql;
247
- drop view &tempds;
248
- drop table &colinfo;
247
+ drop table &colinfo, &tempds;
249
248
 
250
249
  %if &showmeta=YES %then %do;
251
250
  data _null_; file &jref encoding='utf-8' mod;
@@ -0,0 +1,110 @@
1
+ /**
2
+ @file
3
+ @brief Returns the type of the format
4
+ @details
5
+ Returns the type, eg DATE / DATETIME / TIME (based on hard-coded lookup)
6
+ else CHAR / NUM.
7
+
8
+ This macro may be extended in the future to support custom formats - this
9
+ would necessitate a call to `dosubl()` for running a proc format with cntlout.
10
+
11
+ The function itself takes the following (positional) parameters:
12
+
13
+ | PARAMETER | DESCRIPTION |
14
+ |---|---|
15
+ |fmtnm| Format name to be tested. Can be with or without the w.d extension.|
16
+
17
+ Usage:
18
+
19
+ %mcf_getfmttype(wrap=YES, insert_cmplib=YES)
20
+
21
+ data _null_;
22
+ fmt1=mcf_getfmttype('DATE9.');
23
+ fmt2=mcf_getfmttype('DATETIME');
24
+ put (fmt:)(=);
25
+ run;
26
+ %put fmt3=%sysfunc(mcf_getfmttype(TIME9.));
27
+
28
+ Returns:
29
+
30
+ > fmt1=DATE fmt2=DATETIME
31
+ > fmt3=TIME
32
+
33
+ @param [out] wrap= (NO) Choose YES to add the proc fcmp wrapper.
34
+ @param [out] insert_cmplib= (NO) Choose YES to insert the package into the
35
+ CMPLIB reference.
36
+ @param [out] lib= (work) The output library in which to create the catalog.
37
+ @param [out] cat= (sasjs) The output catalog in which to create the package.
38
+ @param [out] pkg= (utils) The output package in which to create the function.
39
+ Uses a 3 part format: libref.catalog.package
40
+
41
+ <h4> SAS Macros </h4>
42
+ @li mcf_init.sas
43
+
44
+ <h4> Related Programs </h4>
45
+ @li mcf_getfmttype.test.sas
46
+ @li mp_init.sas
47
+
48
+ @todo "Custom Format Lookups" To enable site-specific formats, make
49
+ use of a set of SASJS_FMTLIST_(DATATYPE) global variables.
50
+
51
+ **/
52
+
53
+ %macro mcf_getfmttype(wrap=NO
54
+ ,insert_cmplib=NO
55
+ ,lib=WORK
56
+ ,cat=SASJS
57
+ ,pkg=UTILS
58
+ )/*/STORE SOURCE*/;
59
+
60
+ %if %mcf_init(mcf_getfmttype)=1 %then %return;
61
+
62
+ %if &wrap=YES %then %do;
63
+ proc fcmp outlib=&lib..&cat..&pkg;
64
+ %end;
65
+
66
+ function mcf_getfmttype(fmtnm $) $8;
67
+ if substr(fmtnm,1,1)='$' then return('CHAR');
68
+ else do;
69
+ /* extract NAME */
70
+ length fmt $32;
71
+ fmt=scan(fmtnm,1,'.');
72
+ do while (
73
+ substr(fmt,length(fmt),1) in ('1','2','3','4','5','6','7','8','9','0')
74
+ );
75
+ if length(fmt)=1 then fmt='W';
76
+ else fmt=substr(fmt,1,length(fmt)-1);
77
+ end;
78
+
79
+ /* apply lookups */
80
+ if cats(fmt) in ('DATETIME','B8601DN','B8601DN','B8601DT','B8601DT'
81
+ ,'B8601DZ','B8601DZ','DATEAMPM','DTDATE','DTMONYY','DTWKDATX','DTYEAR'
82
+ ,'DTYYQC','E8601DN','E8601DN','E8601DT','E8601DT','E8601DZ','E8601DZ')
83
+ then return('DATETIME');
84
+ else if fmt in ('DATE','YYMMDD','B8601DA','B8601DA','DAY','DDMMYY'
85
+ ,'DDMMYYB','DDMMYYC','DDMMYYD','DDMMYYN','DDMMYYP','DDMMYYS','DDMMYYx'
86
+ ,'DOWNAME','E8601DA','E8601DA','JULDAY','JULIAN','MMDDYY','MMDDYYB'
87
+ ,'MMDDYYC','MMDDYYD','MMDDYYN','MMDDYYP','MMDDYYS','MMDDYYx','MMYY'
88
+ ,'MMYYC','MMYYD','MMYYN','MMYYP','MMYYS','MMYYx','MONNAME','MONTH'
89
+ ,'MONYY','PDJULG','PDJULI','QTR','QTRR','WEEKDATE','WEEKDATX','WEEKDAY'
90
+ ,'WEEKU','WEEKV','WEEKW','WORDDATE','WORDDATX','YEAR','YYMM','YYMMC'
91
+ ,'YYMMD','YYMMDDB','YYMMDDC','YYMMDDD','YYMMDDN','YYMMDDP','YYMMDDS'
92
+ ,'YYMMDDx','YYMMN','YYMMP','YYMMS','YYMMx','YYMON','YYQ','YYQC','YYQD'
93
+ ,'YYQN','YYQP','YYQR','YYQRC','YYQRD','YYQRN','YYQRP','YYQRS','YYQRx'
94
+ ,'YYQS','YYQx','YYQZ') then return('DATE');
95
+ else if fmt in ('TIME','B8601LZ','B8601LZ','B8601TM','B8601TM','B8601TZ'
96
+ ,'B8601TZ','E8601LZ','E8601LZ','E8601TM','E8601TM','E8601TZ','E8601TZ'
97
+ ,'HHMM','HOUR','MMSS','TIMEAMPM','TOD') then return('TIME');
98
+ else return('NUM');
99
+ end;
100
+ endsub;
101
+
102
+ %if &wrap=YES %then %do;
103
+ quit;
104
+ %end;
105
+
106
+ %if &insert_cmplib=YES %then %do;
107
+ options insert=(CMPLIB=(&lib..&cat));
108
+ %end;
109
+
110
+ %mend mcf_getfmttype;
@@ -164,7 +164,7 @@ data _null_;
164
164
  put ' %put &sysmacroname: Switching to DATASTEP engine; ';
165
165
  put ' %goto datastep; ';
166
166
  put ' %end; ';
167
- put ' data &tempds /view=&tempds;set &ds; ';
167
+ put ' data &tempds;set &ds; ';
168
168
  put ' %if &fmt=N %then format _numeric_ best32.;; ';
169
169
  put ' /* PRETTY is necessary to avoid line truncation in large files */ ';
170
170
  put ' proc json out=&jref pretty ';
@@ -215,7 +215,7 @@ data _null_;
215
215
  put ' %end; ';
216
216
  put ' other = [best.]; ';
217
217
  put ' ';
218
- put ' data &tempds/view=&tempds; ';
218
+ put ' data &tempds; ';
219
219
  put ' attrib _all_ label=''''; ';
220
220
  put ' %do i=1 %to &numcols; ';
221
221
  put ' %if &&typelong&i=char or &fmt=Y %then %do; ';
@@ -277,8 +277,7 @@ data _null_;
277
277
  put ' %end; ';
278
278
  put ' ';
279
279
  put ' proc sql; ';
280
- put ' drop view &tempds; ';
281
- put ' drop table &colinfo; ';
280
+ put ' drop table &colinfo, &tempds; ';
282
281
  put ' ';
283
282
  put ' %if &showmeta=YES %then %do; ';
284
283
  put ' data _null_; file &jref encoding=''utf-8'' mod; ';
package/package.json CHANGED
@@ -35,5 +35,5 @@
35
35
  "devDependencies": {
36
36
  "@sasjs/cli": "3.6.0"
37
37
  },
38
- "version": "4.2.0"
38
+ "version": "4.3.0"
39
39
  }
@@ -308,7 +308,7 @@ data _null_;
308
308
  put ' %put &sysmacroname: Switching to DATASTEP engine; ';
309
309
  put ' %goto datastep; ';
310
310
  put ' %end; ';
311
- put ' data &tempds /view=&tempds;set &ds; ';
311
+ put ' data &tempds;set &ds; ';
312
312
  put ' %if &fmt=N %then format _numeric_ best32.;; ';
313
313
  put ' /* PRETTY is necessary to avoid line truncation in large files */ ';
314
314
  put ' proc json out=&jref pretty ';
@@ -359,7 +359,7 @@ data _null_;
359
359
  put ' %end; ';
360
360
  put ' other = [best.]; ';
361
361
  put ' ';
362
- put ' data &tempds/view=&tempds; ';
362
+ put ' data &tempds; ';
363
363
  put ' attrib _all_ label=''''; ';
364
364
  put ' %do i=1 %to &numcols; ';
365
365
  put ' %if &&typelong&i=char or &fmt=Y %then %do; ';
@@ -421,8 +421,7 @@ data _null_;
421
421
  put ' %end; ';
422
422
  put ' ';
423
423
  put ' proc sql; ';
424
- put ' drop view &tempds; ';
425
- put ' drop table &colinfo; ';
424
+ put ' drop table &colinfo, &tempds; ';
426
425
  put ' ';
427
426
  put ' %if &showmeta=YES %then %do; ';
428
427
  put ' data _null_; file &jref encoding=''utf-8'' mod; ';