@sasjs/core 2.53.0 → 2.54.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
@@ -1,7 +1,6 @@
1
1
  # Macro Core
2
2
  [![npm package][npm-image]][npm-url]
3
3
  [![Github Workflow][githubworkflow-image]][githubworkflow-url]
4
- [![Dependency Status][dependency-image]][dependency-url]
5
4
  [![npm](https://img.shields.io/npm/dt/@sasjs/core)]()
6
5
  ![Snyk Vulnerabilities for npm package](https://img.shields.io/snyk/vulnerabilities/npm/@sasjs/core)
7
6
  [![License](https://img.shields.io/apm/l/atomic-design-ui.svg)](/LICENSE)
@@ -16,11 +15,9 @@
16
15
  [npm-url]:http://npmjs.org/package/@sasjs/core
17
16
  [githubworkflow-image]:https://github.com/sasjs/core/actions/workflows/main.yml/badge.svg
18
17
  [githubworkflow-url]:https://github.com/sasjs/core/blob/main/.github/workflows/main.yml
19
- [dependency-image]:https://david-dm.org/sasjs/core.svg
20
18
  [dependency-url]:https://github.com/sasjs/core/blob/main/package.json
21
19
 
22
20
 
23
-
24
21
  Much quality. Many standards. The **Macro Core** library exists to save time and development effort! Herein ye shall find a veritable host of MIT-licenced, production quality SAS macros. These are a mix of tools, utilities, functions and code generators that are useful in the context of [Application Development](https://sasapps.io) on the SAS platform (eg https://datacontroller.io). [Contributions](https://github.com/sasjs/core/blob/main/CONTRIBUTING.md) are welcomed.
25
22
 
26
23
  You can download and compile them all in just two lines of SAS code:
@@ -32,49 +29,61 @@ filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
32
29
 
33
30
  Documentation: https://core.sasjs.io
34
31
 
35
- # Components
32
+ ## Components
36
33
 
37
- **base** library (SAS9/Viya)
34
+ ### **base** library (SAS9/Viya)
38
35
 
39
36
  - OS independent
40
37
  - Not metadata aware
41
38
  - No X command
42
39
  - Prefixes: _mf_, _mp_
43
40
 
44
- **fcmp** library (SAS9/Viya)
41
+ #### **fcmp** library (SAS9/Viya)
45
42
  - Function and macro names are identical, except for special cases
46
43
  - Prefixes: _mcf_
47
44
 
48
45
  The fcmp macros are used to generate fcmp functions, and can be used with or
49
46
  without the `proc fcmp` wrapper.
50
47
 
51
- **meta** library (SAS9 only)
48
+ ### **meta** library (SAS9 only)
49
+
50
+ Macros used in SAS EBI, which connect to the metadata server.
52
51
 
53
52
  - OS independent
54
53
  - Metadata aware
55
54
  - No X command
56
55
  - Prefixes: _mm_
57
56
 
58
- **viya** library (Viya only)
57
+ ### **server** library (@sasjs/server only)
58
+ These macros are used for building applications using [@sasjs/server](https://server.sasjs.io) - an open source REST API for Desktop SAS.
59
+
60
+ - OS independent
61
+ - @sasjs/server aware
62
+ - No X command
63
+ - Prefixes: _ms_
64
+
65
+ ### **viya** library (Viya only)
66
+
67
+ Macros used for interfacing with SAS Viya.
59
68
 
60
69
  - OS independent
61
70
  - No X command
62
- - Prefixes: _mv_
71
+ - Prefixes: _mv_, _mvf_
63
72
 
64
- **metax** library (SAS9 only)
73
+ ### **metax** library (SAS9 only)
65
74
 
66
75
  - OS specific
67
76
  - Metadata aware
68
77
  - X command enabled
69
78
  - Prefixes: _mmw_,_mmu_,_mmx_
70
79
 
71
- **lua** library
80
+ ### **lua** library
72
81
 
73
82
  Wait - this is a macro library - what is LUA doing here? Well, it is a little known fact that you CAN run LUA within a SAS Macro. It has to be written to a text file with a `.lua` extension, from where you can `%include` it. So, without using the `proc lua` wrapper.
74
83
 
75
84
  To contribute, simply write your freeform LUA in the LUA folder. Then run the `build.py`, which will convert your LUA into a data step with put statements, and create the macro wrapper with a `ml_` prefix. You can then use your module in any program by running:
76
85
 
77
- ```
86
+ ```sas
78
87
  /* compile the lua module */
79
88
  %ml_yourmodule()
80
89
 
@@ -89,7 +98,7 @@ run;
89
98
  - X command enabled
90
99
  - Prefixes: _mmw_,_mmu_,_mmx_
91
100
 
92
- # Installation
101
+ ## Installation
93
102
 
94
103
  First, download the repo to a location your SAS system can access. Then update your sasautos path to include the components you wish to have available, eg:
95
104
 
@@ -107,9 +116,9 @@ filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
107
116
  %inc mc;
108
117
  ```
109
118
 
110
- # Standards
119
+ ## Standards
111
120
 
112
- ## File Properties
121
+ ### File Properties
113
122
 
114
123
  - filenames much match macro names
115
124
  - filenames must be lowercase, without spaces
@@ -117,19 +126,20 @@ filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
117
126
  - one macro per file
118
127
  - prefixes:
119
128
  - _mf_ for macro functions (can be used in open code).
120
- - _mp_ for macro procedures (which generate sas code)
129
+ - _ml_ for macros that are used to compile LUA modules
121
130
  - _mm_ for metadata macros (interface with the metadata server).
122
131
  - _mmx_ for macros that use metadata and are XCMD enabled
132
+ - _mp_ for macro procedures (which generate sas code)
133
+ - _ms_ for macro procedures that will only work with [@sasjs/server](https://github.com/sasjs/server)
134
+ - _mv_ for macro procedures that will only work in Viya
123
135
  - _mx_ for macros that are XCMD enabled
124
- - _ml_ for macros that are used to compile LUA modules
125
- - _mv_ for macros that will only work in Viya
126
136
  - follow verb-noun convention
127
137
  - unix style line endings (lf)
128
138
  - individual lines should be no more than 80 characters long
129
139
  - UTF-8
130
140
 
131
141
 
132
- ## Header Properties
142
+ ### Header Properties
133
143
 
134
144
  The **Macro Core** documentation is created using [doxygen](http://www.doxygen.nl). A full list of attributes can be found [here](http://www.doxygen.nl/manual/commands.html) but the following are most relevant:
135
145
 
@@ -143,7 +153,7 @@ The **Macro Core** documentation is created using [doxygen](http://www.doxygen.n
143
153
 
144
154
  All macros must be commented in the doxygen format, to enable the [online documentation](https://core.sasjs.io).
145
155
 
146
- ### Dependencies
156
+ #### Dependencies
147
157
  SAS code can contain one of two types of dependency - SAS Macros, and SAS Includes. When compiling projects using the [SASjs CLI](https://cli.sasjs.io) the doxygen header is scanned for ` @li` items under the following headers:
148
158
 
149
159
  ```sas
@@ -161,7 +171,7 @@ The CLI can then extract all the dependencies and insert as precode (SAS Macros)
161
171
  When contributing to this library, it is therefore important to ensure that all dependencies are listed in the header in this format.
162
172
 
163
173
 
164
- ## Coding Standards
174
+ ### Coding Standards
165
175
 
166
176
  - Indentation = 2 spaces. No tabs!
167
177
  - no trailing white space
@@ -174,7 +184,7 @@ When contributing to this library, it is therefore important to ensure that all
174
184
  - Avoid naming collisions! All macro variables should be local scope. Use system generated work tables where possible - eg `data ; set sashelp.class; run; data &output; set &syslast; run;`
175
185
  - The use of `quit;` for `proc sql` is optional unless you are looking to benefit from the timing statistics.
176
186
 
177
- # General Notes
187
+ ## General Notes
178
188
 
179
189
  - All macros should be compatible with SAS versions from support level B and above (so currently 9.2 and later). If an earlier version is not supported, then the macro should say as such in the header documentation, and exit gracefully (eg `%if %sysevalf(&sysver<9.3) %then %return`).
180
190
 
@@ -186,7 +196,6 @@ If you find this library useful, please leave a [star](https://github.com/sasjs/
186
196
 
187
197
 
188
198
 
189
-
190
199
  ## Contributors ✨
191
200
  <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
192
201
  [![All Contributors](https://img.shields.io/badge/all_contributors-10-orange.svg?style=flat-square)](#contributors-)
package/package.json CHANGED
@@ -35,5 +35,5 @@
35
35
  "devDependencies": {
36
36
  "@sasjs/cli": "^2.39.0"
37
37
  },
38
- "version": "2.53.0"
38
+ "version": "2.54.0"
39
39
  }
@@ -0,0 +1,170 @@
1
+ /**
2
+ @file
3
+ @brief Send data to/from @sasjs/server
4
+ @details This macro should be added to the start of each web service,
5
+ **immediately** followed by a call to:
6
+
7
+ %ms_webout(FETCH)
8
+
9
+ This will read all the input data and create same-named SAS datasets in the
10
+ WORK library. You can then insert your code, and send data back using the
11
+ following syntax:
12
+
13
+ data some datasets; * make some data ;
14
+ retain some columns;
15
+ run;
16
+
17
+ %ms_webout(OPEN)
18
+ %ms_webout(ARR,some) * Array format, fast, suitable for large tables ;
19
+ %ms_webout(OBJ,datasets) * Object format, easier to work with ;
20
+ %ms_webout(CLOSE)
21
+
22
+
23
+ @param action Either FETCH, OPEN, ARR, OBJ or CLOSE
24
+ @param ds The dataset to send back to the frontend
25
+ @param dslabel= value to use instead of the real name for sending to JSON
26
+ @param fmt=(Y) Set to N to send back unformatted values
27
+ @param fref=(_webout) The fileref to which to write the JSON
28
+
29
+ <h4> SAS Macros </h4>
30
+ @li mp_jsonout.sas
31
+ @li mf_getuser.sas
32
+
33
+ <h4> Related Macros </h4>
34
+ @li mv_webout.sas
35
+ @li mm_webout.sas
36
+
37
+ @version 9.3
38
+ @author Allan Bowe
39
+
40
+ **/
41
+
42
+ %macro ms_webout(action,ds,dslabel=,fref=_webout,fmt=Y);
43
+ %global _webin_file_count _webin_fileref1 _webin_name1 _program _debug
44
+ sasjs_tables;
45
+
46
+ %local i tempds;
47
+ %let action=%upcase(&action);
48
+
49
+ %if &action=FETCH %then %do;
50
+ %if %str(&_debug) ge 131 %then %do;
51
+ options mprint notes mprintnest;
52
+ %end;
53
+ %let _webin_file_count=%eval(&_webin_file_count+0);
54
+ /* now read in the data */
55
+ %do i=1 %to &_webin_file_count;
56
+ %if &_webin_file_count=1 %then %do;
57
+ %let _webin_fileref1=&_webin_fileref;
58
+ %let _webin_name1=&_webin_name;
59
+ %end;
60
+ data _null_;
61
+ infile &&_webin_fileref&i termstr=crlf;
62
+ input;
63
+ call symputx('input_statement',_infile_);
64
+ putlog "&&_webin_name&i input statement: " _infile_;
65
+ stop;
66
+ data &&_webin_name&i;
67
+ infile &&_webin_fileref&i firstobs=2 dsd termstr=crlf encoding='utf-8';
68
+ input &input_statement;
69
+ %if %str(&_debug) ge 131 %then %do;
70
+ if _n_<20 then putlog _infile_;
71
+ %end;
72
+ run;
73
+ %let sasjs_tables=&sasjs_tables &&_webin_name&i;
74
+ %end;
75
+ %end;
76
+
77
+ %else %if &action=OPEN %then %do;
78
+ /* fix encoding */
79
+ OPTIONS NOBOMFILE;
80
+
81
+ /* setup json */
82
+ data _null_;file &fref encoding='utf-8';
83
+ %if %str(&_debug) ge 131 %then %do;
84
+ put '>>weboutBEGIN<<';
85
+ %end;
86
+ put '{"SYSDATE" : "' "&SYSDATE" '"';
87
+ put ',"SYSTIME" : "' "&SYSTIME" '"';
88
+ run;
89
+
90
+ %end;
91
+
92
+ %else %if &action=ARR or &action=OBJ %then %do;
93
+ %mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt,jref=&fref
94
+ ,engine=&jsonengine,dbg=%str(&_debug)
95
+ )
96
+ %end;
97
+ %else %if &action=CLOSE %then %do;
98
+ %if %str(&_debug) ge 131 %then %do;
99
+ /* if debug mode, send back first 10 records of each work table also */
100
+ options obs=10;
101
+ data;run;%let tempds=%scan(&syslast,2,.);
102
+ ods output Members=&tempds;
103
+ proc datasets library=WORK memtype=data;
104
+ %local wtcnt;%let wtcnt=0;
105
+ data _null_;
106
+ set &tempds;
107
+ if not (upcase(name) =:"DATA"); /* ignore temp datasets */
108
+ i+1;
109
+ call symputx('wt'!!left(i),name,'l');
110
+ call symputx('wtcnt',i,'l');
111
+ data _null_; file &fref mod encoding='utf-8';
112
+ put ",""WORK"":{";
113
+ %do i=1 %to &wtcnt;
114
+ %let wt=&&wt&i;
115
+ proc contents noprint data=&wt
116
+ out=_data_ (keep=name type length format:);
117
+ run;%let tempds=%scan(&syslast,2,.);
118
+ data _null_; file &fref mod encoding='utf-8';
119
+ dsid=open("WORK.&wt",'is');
120
+ nlobs=attrn(dsid,'NLOBS');
121
+ nvars=attrn(dsid,'NVARS');
122
+ rc=close(dsid);
123
+ if &i>1 then put ','@;
124
+ put " ""&wt"" : {";
125
+ put '"nlobs":' nlobs;
126
+ put ',"nvars":' nvars;
127
+ %mp_jsonout(OBJ,&tempds,jref=&fref,dslabel=colattrs,engine=&jsonengine)
128
+ %mp_jsonout(OBJ,&wt,jref=&fref,dslabel=first10rows,engine=&jsonengine)
129
+ data _null_; file &fref mod encoding='utf-8';
130
+ put "}";
131
+ %end;
132
+ data _null_; file &fref mod encoding='utf-8';
133
+ put "}";
134
+ run;
135
+ %end;
136
+ /* close off json */
137
+ data _null_;file &fref mod encoding='utf-8';
138
+ _PROGRAM=quote(trim(resolve(symget('_PROGRAM'))));
139
+ put ",""SYSUSERID"" : ""&sysuserid"" ";
140
+ put ",""MF_GETUSER"" : ""%mf_getuser()"" ";
141
+ put ",""_DEBUG"" : ""&_debug"" ";
142
+ put ',"_PROGRAM" : ' _PROGRAM ;
143
+ put ",""SYSCC"" : ""&syscc"" ";
144
+ put ",""SYSERRORTEXT"" : ""&syserrortext"" ";
145
+ SYSHOSTINFOLONG=quote(trim(symget('SYSHOSTINFOLONG')));
146
+ put ',"SYSHOSTINFOLONG" : ' SYSHOSTINFOLONG;
147
+ put ",""SYSHOSTNAME"" : ""&syshostname"" ";
148
+ put ",""SYSPROCESSID"" : ""&SYSPROCESSID"" ";
149
+ put ",""SYSPROCESSMODE"" : ""&SYSPROCESSMODE"" ";
150
+ put ",""SYSPROCESSNAME"" : ""&SYSPROCESSNAME"" ";
151
+ put ",""SYSJOBID"" : ""&sysjobid"" ";
152
+ put ",""SYSSCPL"" : ""&sysscpl"" ";
153
+ put ",""SYSSITE"" : ""&syssite"" ";
154
+ put ",""SYSTCPIPHOSTNAME"" : ""&SYSTCPIPHOSTNAME"" ";
155
+ sysvlong=quote(trim(symget('sysvlong')));
156
+ put ',"SYSVLONG" : ' sysvlong;
157
+ put ",""SYSWARNINGTEXT"" : ""&syswarningtext"" ";
158
+ put ',"END_DTTM" : "' "%sysfunc(datetime(),datetime20.3)" '" ';
159
+ autoexec=quote(trim(getoption('autoexec')));
160
+ put ',"AUTOEXEC" : ' autoexec;
161
+ memsize="%sysfunc(INPUTN(%sysfunc(getoption(memsize)), best.),sizekmg.)";
162
+ put ',"MEMSIZE" : ' memsize;
163
+ put "}" @;
164
+ %if %str(&_debug) ge 131 %then %do;
165
+ put '>>weboutEND<<';
166
+ %end;
167
+ run;
168
+ %end;
169
+
170
+ %mend ms_webout;
package/.editorconfig DELETED
@@ -1,12 +0,0 @@
1
- # http://editorconfig.org
2
- root = true
3
-
4
- [*]
5
- charset = utf-8
6
- indent_style = space
7
- indent_size = 2
8
- end_of_line = lf
9
- insert_final_newline = false
10
- trim_trailing_whitespace = true
11
-
12
-
package/CHANGELOG.md DELETED
@@ -1,5 +0,0 @@
1
- # CHANGELOG
2
-
3
- As the changes are managed automatically in github, we don't generate an additional changelog. To view the fixes/features in each release, check out the releases page below:
4
-
5
- [https://github.com/sasjs/core/releases](https://github.com/sasjs/core/releases)