@sasjs/core 4.35.3 → 4.37.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/README.md CHANGED
@@ -36,21 +36,21 @@ Documentation: https://core.sasjs.io
36
36
  - OS independent
37
37
  - Works on all SAS Platforms
38
38
  - No X command
39
- - Prefixes: _mf_, _mp_
39
+ - Prefixes: `mf_`, `mp_`
40
40
 
41
41
  ### DDL folder (All Platforms)
42
42
 
43
43
  - OS independent
44
44
  - Works on all SAS Platforms
45
45
  - No X command
46
- - Prefixes: _mddl_(lib)_ -> where lib can be "SAS" (in relation to a SAS component) or "DC" (in relation to a Data Controller component)
46
+ - Prefixes: `mddl_(lib)_` -> where lib can be "SAS" (in relation to a SAS component) or "DC" (in relation to a Data Controller component)
47
47
 
48
48
  This library will not be used for storing data entries (such as formats or datalines). Where this becomes necessary in the future, a new repo will be created, in order to keep the NPM bundle size down (for the benefit of those looking to embed purely macros in their applications).
49
49
 
50
50
  ### FCMP folder (All Platforms)
51
51
 
52
52
  - Function and macro names are identical, except for special cases
53
- - Prefixes: _mcf_
53
+ - Prefixes: `mcf_`
54
54
 
55
55
  The fcmp macros are used to generate fcmp functions, and can be used with or without the `proc fcmp` wrapper.
56
56
 
@@ -72,7 +72,7 @@ endsubmit;
72
72
  run;
73
73
  ```
74
74
 
75
- - Prefixes: _ml_
75
+ - Prefixes: `ml_`
76
76
 
77
77
  ### META folder (SAS9 only)
78
78
 
@@ -81,14 +81,14 @@ Macros used in SAS EBI, which connect to the metadata server.
81
81
  - OS independent
82
82
  - Metadata aware
83
83
  - No X command
84
- - Prefixes: _mm_
84
+ - Prefixes: `mm_`
85
85
 
86
86
  ### METAX folder (SAS9 only)
87
87
 
88
88
  - OS specific
89
89
  - Metadata aware
90
90
  - X command enabled
91
- - Prefixes: _mmw_,_mmu_,_mmx_
91
+ - Prefixes: `mmx_`
92
92
 
93
93
  ### SERVER folder (@sasjs/server only)
94
94
  These macros are used for building applications using [@sasjs/server](https://server.sasjs.io) - an open source REST API for Desktop SAS.
@@ -96,7 +96,7 @@ These macros are used for building applications using [@sasjs/server](https://se
96
96
  - OS independent
97
97
  - @sasjs/server aware
98
98
  - No X command
99
- - Prefixes: _ms_
99
+ - Prefixes: `ms_`
100
100
 
101
101
  ### VIYA folder (Viya only)
102
102
 
@@ -104,7 +104,7 @@ Macros used for interfacing with SAS Viya.
104
104
 
105
105
  - OS independent
106
106
  - No X command
107
- - Prefixes: _mv_, _mvf_
107
+ - Prefixes: `mv_`, `mvf_`
108
108
 
109
109
  ### XPLATFORM folder (Viya, Meta, and Server)
110
110
 
@@ -112,7 +112,7 @@ Sometimes it is helpful to use a macro that can be used interchangeably regardle
112
112
 
113
113
  - OS independent
114
114
  - No X command
115
- - Prefixes: _mx_
115
+ - Prefixes: `mx_`
116
116
 
117
117
  ## Installation
118
118
 
@@ -0,0 +1,99 @@
1
+ /**
2
+ @file
3
+ @brief Export dataset metadata to a single output table
4
+ @details Exports the dataset attributes and enginehost information, then
5
+ converts the datasets into a single output table in the following format:
6
+
7
+ |ODS_TABLE:$10.|NAME:$100.|VALUE:$1000.|
8
+ |---|---|---|
9
+ |`ATTRIBUTES `|`Data Set Name `|`SASHELP.CLASS `|
10
+ |`ATTRIBUTES `|`Observations `|`19 `|
11
+ |`ATTRIBUTES `|`Member Type `|`DATA `|
12
+ |`ATTRIBUTES `|`Variables `|`5 `|
13
+ |`ATTRIBUTES `|`Engine `|`V9 `|
14
+ |`ATTRIBUTES `|`Indexes `|`0 `|
15
+ |`ATTRIBUTES `|`Created `|`06/08/2020 00:59:14 `|
16
+ |`ATTRIBUTES `|`Observation Length `|`40 `|
17
+ |`ATTRIBUTES `|`Last Modified `|`06/08/2020 00:59:14 `|
18
+ |`ATTRIBUTES `|`Deleted Observations `|`0 `|
19
+ |`ATTRIBUTES `|`Protection `|`. `|
20
+ |`ATTRIBUTES `|`Compressed `|`NO `|
21
+ |`ATTRIBUTES `|`Data Set Type `|`. `|
22
+ |`ATTRIBUTES `|`Sorted `|`NO `|
23
+ |`ATTRIBUTES `|`Label `|`Student Data `|
24
+ |`ATTRIBUTES `|`Data Representation `|`SOLARIS_X86_64, LINUX_X86_64, ALPHA_TRU64, LINUX_IA64 `|
25
+ |`ATTRIBUTES `|`Encoding `|`us-ascii ASCII (ANSI) `|
26
+ |`ENGINEHOST `|`Data Set Page Size `|`65536 `|
27
+ |`ENGINEHOST `|`Number of Data Set Pages `|`1 `|
28
+ |`ENGINEHOST `|`First Data Page `|`1 `|
29
+ |`ENGINEHOST `|`Max Obs per Page `|`1632 `|
30
+ |`ENGINEHOST `|`Obs in First Data Page `|`19 `|
31
+ |`ENGINEHOST `|`Number of Data Set Repairs `|`0 `|
32
+ |`ENGINEHOST `|`Filename `|`/opt/sas/sas9/SASHome/SASFoundation/9.4/sashelp/class.sas7bdat `|
33
+ |`ENGINEHOST `|`Release Created `|`9.0401M7 `|
34
+ |`ENGINEHOST `|`Host Created `|`Linux `|
35
+ |`ENGINEHOST `|`Inode Number `|`28314616 `|
36
+ |`ENGINEHOST `|`Access Permission `|`rw-r--r-- `|
37
+ |`ENGINEHOST `|`Owner Name `|`sas `|
38
+ |`ENGINEHOST `|`File Size `|`128KB `|
39
+ |`ENGINEHOST `|`File Size (bytes) `|`131072 `|
40
+
41
+ Example usage:
42
+
43
+ %mp_dsmeta(work.sashelp,outds=work.mymeta)
44
+ proc print data=work.mymeta;
45
+ run;
46
+
47
+ @param libds The library.dataset to export the metadata for
48
+ @param outds= (work.dsmeta) The output table to contain the metadata
49
+
50
+ <h4> Related Files </h4>
51
+ @li mp_dsmeta.test.sas
52
+
53
+ **/
54
+
55
+ %macro mp_dsmeta(libds,outds=work.dsmeta);
56
+
57
+ %local ds1 ds2;
58
+ data;run; %let ds1=&syslast;
59
+ data;run; %let ds2=&syslast;
60
+
61
+ /* setup the ODS capture */
62
+ ods output attributes=&ds1 enginehost=&ds2;
63
+
64
+ /* export the metadata */
65
+ proc contents data=&libds;
66
+ run;
67
+
68
+ /* load it into a single table */
69
+ data &outds (keep=ods_table name value);
70
+ length ods_table $10 name label2 label1 label $100
71
+ value cvalue cvalue1 cvalue2 $1000
72
+ nvalue nvalue1 nvalue2 8;
73
+ if _n_=1 then call missing (of _all_);
74
+ * putlog (_all_)(=);
75
+ set &ds1 (in=atrs) &ds2 (in=eng);
76
+ if atrs then do;
77
+ ods_table='ATTRIBUTES';
78
+ name=coalescec(label1,label);
79
+ value=coalescec(cvalue1,cvalue,put(coalesce(nvalue1,nvalue),best.));
80
+ output;
81
+ if label2 ne '' then do;
82
+ name=label2;
83
+ value=coalescec(cvalue2,put(nvalue2,best.));
84
+ output;
85
+ end;
86
+ end;
87
+ else if eng then do;
88
+ ods_table='ENGINEHOST';
89
+ name=coalescec(label1,label);
90
+ value=coalescec(cvalue1,cvalue,put(coalesce(nvalue1,nvalue),best.));
91
+ output;
92
+ end;
93
+ run;
94
+
95
+ proc sql;
96
+ drop table &ds1, &ds2;
97
+
98
+ %mend mp_dsmeta;
99
+
@@ -62,7 +62,7 @@
62
62
  @param [in] maxobs= (MAX) Provide an integer to limit the number of input rows
63
63
  that should be converted to JSON
64
64
 
65
- <h4> Related Macros </h4>
65
+ <h4> Related Files </h4>
66
66
  @li mp_ds2fmtds.sas
67
67
 
68
68
  @version 9.2
@@ -210,7 +210,7 @@
210
210
  order by 1;
211
211
  create table &tmpds2(
212
212
  FMTNAME char(32),
213
- MAX num length=3
213
+ LENGTH num
214
214
  );
215
215
  %local catlist cat fmtlist i;
216
216
  select distinct fmtcat into: catlist separated by ' ' from &tmpds1;
@@ -219,16 +219,16 @@
219
219
  proc sql;
220
220
  select distinct fmtname into: fmtlist separated by ' '
221
221
  from &tmpds1 where fmtcat="&cat";
222
- proc format lib=&cat cntlout=&tmpds3(keep=fmtname max);
222
+ proc format lib=&cat cntlout=&tmpds3(keep=fmtname length);
223
223
  select &fmtlist;
224
224
  run;
225
225
  proc sql;
226
- insert into &tmpds2 select distinct fmtname,max from &tmpds3;
226
+ insert into &tmpds2 select distinct fmtname,length from &tmpds3;
227
227
  %end;
228
228
 
229
229
  proc sql;
230
230
  create table &tmpds4 as
231
- select a.*, b.max as maxw
231
+ select a.*, b.length as maxw
232
232
  from &colinfo a
233
233
  left join &tmpds2 b
234
234
  on cats(a.format)=cats(upcase(b.fmtname))
@@ -233,7 +233,7 @@ data _null_;
233
233
  put ' order by 1; ';
234
234
  put ' create table &tmpds2( ';
235
235
  put ' FMTNAME char(32), ';
236
- put ' MAX num length=3 ';
236
+ put ' LENGTH num ';
237
237
  put ' ); ';
238
238
  put ' %local catlist cat fmtlist i; ';
239
239
  put ' select distinct fmtcat into: catlist separated by '' '' from &tmpds1; ';
@@ -242,16 +242,16 @@ data _null_;
242
242
  put ' proc sql; ';
243
243
  put ' select distinct fmtname into: fmtlist separated by '' '' ';
244
244
  put ' from &tmpds1 where fmtcat="&cat"; ';
245
- put ' proc format lib=&cat cntlout=&tmpds3(keep=fmtname max); ';
245
+ put ' proc format lib=&cat cntlout=&tmpds3(keep=fmtname length); ';
246
246
  put ' select &fmtlist; ';
247
247
  put ' run; ';
248
248
  put ' proc sql; ';
249
- put ' insert into &tmpds2 select distinct fmtname,max from &tmpds3; ';
249
+ put ' insert into &tmpds2 select distinct fmtname,length from &tmpds3; ';
250
250
  put ' %end; ';
251
251
  put ' ';
252
252
  put ' proc sql; ';
253
253
  put ' create table &tmpds4 as ';
254
- put ' select a.*, b.max as maxw ';
254
+ put ' select a.*, b.length as maxw ';
255
255
  put ' from &colinfo a ';
256
256
  put ' left join &tmpds2 b ';
257
257
  put ' on cats(a.format)=cats(upcase(b.fmtname)) ';
@@ -0,0 +1,67 @@
1
+ /**
2
+ @file
3
+ @brief Get the properties of a Stored Process
4
+ @details Extracts various properties and creates an output table in the
5
+ structure below:
6
+
7
+ |STP_URI:$200.|SERVERCONTEXT:$200.|STOREDPROCESSCONFIGURATION:$1000.|SOURCECODE_FIRST32K:$32767.|PATH:$76.|
8
+ |---|---|---|---|---|
9
+ |`A5DN9TDQ.BH0000C8 `|`SASApp `|`<?xml version="1.0" encoding="UTF-8"?><StoredProcess><ServerContext LogicalServerType="Sps" OtherAllowed="false"/><ResultCapabilities Package="false" Streaming="true"/><OutputParameters/></StoredProcess> `|`%put first 32767 bytes of code; `|`/path/to/my/stp`|
10
+
11
+ @param [in] pgm The metadata path of the Stored Process
12
+ @param [out] outds= (work.mm_getstpinfo) The output table to create
13
+ @param [in] mdebug= (0) Set to 1 to enable DEBUG messages
14
+
15
+ <h4> Related Files </h4>
16
+ @li mm_getstpcode.sas
17
+ @li mm_getstps.sas
18
+ @li mm_createstp.sas
19
+ @li mm_deletestp.sas
20
+
21
+ **/
22
+
23
+ %macro mm_getstpinfo(pgm
24
+ ,outds=work.mm_getstpinfo
25
+ ,mDebug=0
26
+ );
27
+
28
+ %local mD;
29
+ %if &mDebug=1 %then %let mD=;
30
+ %else %let mD=%str(*);
31
+ %&mD.put Executing &sysmacroname..sas;
32
+ %&mD.put _local_;
33
+
34
+ data &outds;
35
+ length type stp_uri tsuri servercontext value $200
36
+ StoredProcessConfiguration $1000 sourcecode_first32k $32767;
37
+ keep path stp_uri sourcecode_first32k StoredProcessConfiguration
38
+ servercontext;
39
+ call missing (of _all_);
40
+ path="&pgm(StoredProcess)";
41
+ /* first, find the STP ID */
42
+ if metadata_pathobj("",path,"StoredProcess",type,stp_uri)>0 then do;
43
+ /* get attributes */
44
+ cnt=1;
45
+ do while (metadata_getnasn(stp_uri,"Notes",cnt,tsuri)>0);
46
+ rc1=metadata_getattr(tsuri,"Name",value);
47
+ &mD.put tsuri= value=;
48
+ if value="SourceCode" then do;
49
+ rc2=metadata_getattr(tsuri,"StoredText",sourcecode_first32k);
50
+ end;
51
+ else if value="Stored Process" then do;
52
+ rc3=metadata_getattr(tsuri,"StoredText",StoredProcessConfiguration);
53
+ end;
54
+ cnt+1;
55
+ end;
56
+ /* get context (should only be one) */
57
+ rc4=metadata_getnasn(stp_uri,"ComputeLocations",1,tsuri);
58
+ rc5=metadata_getattr(tsuri,"Name",servercontext);
59
+ end;
60
+ else do;
61
+ put "%str(ERR)OR: could not find " pgm;
62
+ put (_all_)(=);
63
+ end;
64
+ &md.put (_all_)(=);
65
+ run;
66
+
67
+ %mend mm_getstpinfo ;
package/package.json CHANGED
@@ -35,5 +35,5 @@
35
35
  "devDependencies": {
36
36
  "@sasjs/cli": "3.13.0"
37
37
  },
38
- "version": "4.35.3"
38
+ "version": "4.37.0"
39
39
  }
@@ -234,7 +234,7 @@ data _null_;
234
234
  put ' order by 1; ';
235
235
  put ' create table &tmpds2( ';
236
236
  put ' FMTNAME char(32), ';
237
- put ' MAX num length=3 ';
237
+ put ' LENGTH num ';
238
238
  put ' ); ';
239
239
  put ' %local catlist cat fmtlist i; ';
240
240
  put ' select distinct fmtcat into: catlist separated by '' '' from &tmpds1; ';
@@ -243,16 +243,16 @@ data _null_;
243
243
  put ' proc sql; ';
244
244
  put ' select distinct fmtname into: fmtlist separated by '' '' ';
245
245
  put ' from &tmpds1 where fmtcat="&cat"; ';
246
- put ' proc format lib=&cat cntlout=&tmpds3(keep=fmtname max); ';
246
+ put ' proc format lib=&cat cntlout=&tmpds3(keep=fmtname length); ';
247
247
  put ' select &fmtlist; ';
248
248
  put ' run; ';
249
249
  put ' proc sql; ';
250
- put ' insert into &tmpds2 select distinct fmtname,max from &tmpds3; ';
250
+ put ' insert into &tmpds2 select distinct fmtname,length from &tmpds3; ';
251
251
  put ' %end; ';
252
252
  put ' ';
253
253
  put ' proc sql; ';
254
254
  put ' create table &tmpds4 as ';
255
- put ' select a.*, b.max as maxw ';
255
+ put ' select a.*, b.length as maxw ';
256
256
  put ' from &colinfo a ';
257
257
  put ' left join &tmpds2 b ';
258
258
  put ' on cats(a.format)=cats(upcase(b.fmtname)) ';
@@ -376,7 +376,7 @@ data _null_;
376
376
  put ' order by 1; ';
377
377
  put ' create table &tmpds2( ';
378
378
  put ' FMTNAME char(32), ';
379
- put ' MAX num length=3 ';
379
+ put ' LENGTH num ';
380
380
  put ' ); ';
381
381
  put ' %local catlist cat fmtlist i; ';
382
382
  put ' select distinct fmtcat into: catlist separated by '' '' from &tmpds1; ';
@@ -385,16 +385,16 @@ data _null_;
385
385
  put ' proc sql; ';
386
386
  put ' select distinct fmtname into: fmtlist separated by '' '' ';
387
387
  put ' from &tmpds1 where fmtcat="&cat"; ';
388
- put ' proc format lib=&cat cntlout=&tmpds3(keep=fmtname max); ';
388
+ put ' proc format lib=&cat cntlout=&tmpds3(keep=fmtname length); ';
389
389
  put ' select &fmtlist; ';
390
390
  put ' run; ';
391
391
  put ' proc sql; ';
392
- put ' insert into &tmpds2 select distinct fmtname,max from &tmpds3; ';
392
+ put ' insert into &tmpds2 select distinct fmtname,length from &tmpds3; ';
393
393
  put ' %end; ';
394
394
  put ' ';
395
395
  put ' proc sql; ';
396
396
  put ' create table &tmpds4 as ';
397
- put ' select a.*, b.max as maxw ';
397
+ put ' select a.*, b.length as maxw ';
398
398
  put ' from &colinfo a ';
399
399
  put ' left join &tmpds2 b ';
400
400
  put ' on cats(a.format)=cats(upcase(b.fmtname)) ';