@sasjs/core 4.16.1 → 4.18.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 +9 -0
- package/base/mf_deletefile.sas +31 -0
- package/base/mf_existfeature.sas +7 -6
- package/base/mp_abort.sas +2 -2
- package/base/mp_loadformat.sas +5 -3
- package/meta/mm_spkexport.sas +13 -5
- package/package.json +1 -1
- package/server/ms_deletefile.sas +35 -0
- package/server/ms_getfile.sas +1 -1
package/README.md
CHANGED
|
@@ -217,6 +217,15 @@ If you find this library useful, please leave a [star](https://github.com/sasjs/
|
|
|
217
217
|
|
|
218
218
|

|
|
219
219
|
|
|
220
|
+
## Other SAS Repositories
|
|
221
|
+
|
|
222
|
+
The following repositories are also worth checking out:
|
|
223
|
+
|
|
224
|
+
* [chris-swenson/sasmacros](https://github.com/chris-swenson/sasmacros)
|
|
225
|
+
* [greg-wotton/sas-programs](https://github.com/greg-wootton/sas-programs)
|
|
226
|
+
* [KatjaGlassConsulting/SMILE-SmartSASMacros](https://github.com/KatjaGlassConsulting/SMILE-SmartSASMacros)
|
|
227
|
+
* [scottbass/sas](https://github.com/scottbass/SAS)
|
|
228
|
+
* [yabwon/sas_packages](https://github.com/yabwon/SAS_PACKAGES)
|
|
220
229
|
|
|
221
230
|
## Contributors ✨
|
|
222
231
|
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
@file
|
|
3
|
+
@brief Deletes a physical file, if it exists
|
|
4
|
+
@details Usage:
|
|
5
|
+
|
|
6
|
+
%mf_writefile(&sasjswork/myfile.txt,l1=some content)
|
|
7
|
+
|
|
8
|
+
%mf_deletefile(&sasjswork/myfile.txt)
|
|
9
|
+
|
|
10
|
+
%mf_deletefile(&sasjswork/myfile.txt)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@param filepath Full path to the target file
|
|
14
|
+
|
|
15
|
+
@returns The return code from the fdelete() invocation
|
|
16
|
+
|
|
17
|
+
<h4> Related Macros </h4>
|
|
18
|
+
@li mf_deletefile.test.sas
|
|
19
|
+
@li mf_writefile.sas
|
|
20
|
+
|
|
21
|
+
@version 9.2
|
|
22
|
+
@author Allan Bowe
|
|
23
|
+
**/
|
|
24
|
+
|
|
25
|
+
%macro mf_deletefile(file
|
|
26
|
+
)/*/STORE SOURCE*/;
|
|
27
|
+
%local rc fref;
|
|
28
|
+
%let rc= %sysfunc(filename(fref,&file));
|
|
29
|
+
%if %sysfunc(fdelete(&fref)) ne 0 %then %put %sysfunc(sysmsg());
|
|
30
|
+
%let rc= %sysfunc(filename(fref));
|
|
31
|
+
%mend mf_deletefile;
|
package/base/mf_existfeature.sas
CHANGED
|
@@ -9,19 +9,17 @@
|
|
|
9
9
|
|
|
10
10
|
%put %mf_existfeature(PROCLUA);
|
|
11
11
|
|
|
12
|
-
@param feature
|
|
12
|
+
@param [in] feature The feature to detect.
|
|
13
13
|
|
|
14
14
|
@return output returns 1 or 0 (or -1 if not found)
|
|
15
15
|
|
|
16
16
|
<h4> SAS Macros </h4>
|
|
17
17
|
@li mf_getplatform.sas
|
|
18
18
|
|
|
19
|
-
|
|
20
19
|
@version 8
|
|
21
20
|
@author Allan Bowe
|
|
22
21
|
**/
|
|
23
22
|
/** @cond */
|
|
24
|
-
|
|
25
23
|
%macro mf_existfeature(feature
|
|
26
24
|
)/*/STORE SOURCE*/;
|
|
27
25
|
%let feature=%upcase(&feature);
|
|
@@ -29,7 +27,11 @@
|
|
|
29
27
|
%let platform=%mf_getplatform();
|
|
30
28
|
|
|
31
29
|
%if &feature= %then %do;
|
|
32
|
-
%put
|
|
30
|
+
%put No feature was requested for detection;
|
|
31
|
+
%end;
|
|
32
|
+
%else %if &feature=COLCONSTRAINTS %then %do;
|
|
33
|
+
%if %substr(&sysver,1,1)=4 %then 0;
|
|
34
|
+
%else 1;
|
|
33
35
|
%end;
|
|
34
36
|
%else %if &feature=PROCLUA %then %do;
|
|
35
37
|
/* https://blogs.sas.com/content/sasdummy/2015/08/03/using-lua-within-your-sas-programs */
|
|
@@ -43,5 +45,4 @@
|
|
|
43
45
|
%put &sysmacroname: &feature not found;
|
|
44
46
|
%end;
|
|
45
47
|
%mend mf_existfeature;
|
|
46
|
-
|
|
47
|
-
/** @endcond */
|
|
48
|
+
/** @endcond */
|
package/base/mp_abort.sas
CHANGED
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
%end;
|
|
86
86
|
|
|
87
87
|
/* Stored Process Server web app context */
|
|
88
|
-
%if %symexist(
|
|
88
|
+
%if %symexist(_metaport)
|
|
89
89
|
or "&SYSPROCESSNAME "="Compute Server "
|
|
90
90
|
or &mode=INCLUDE
|
|
91
91
|
%then %do;
|
|
@@ -260,4 +260,4 @@
|
|
|
260
260
|
%end;
|
|
261
261
|
%mend mp_abort;
|
|
262
262
|
|
|
263
|
-
/** @endcond */
|
|
263
|
+
/** @endcond */
|
package/base/mp_loadformat.sas
CHANGED
|
@@ -134,7 +134,7 @@ run;
|
|
|
134
134
|
* First, extract only relevant formats from the catalog
|
|
135
135
|
*/
|
|
136
136
|
proc sql noprint;
|
|
137
|
-
select distinct fmtname into: fmtlist separated by ' ' from &libds;
|
|
137
|
+
select distinct upcase(fmtname) into: fmtlist separated by ' ' from &libds;
|
|
138
138
|
|
|
139
139
|
%mp_cntlout(libcat=&libcat,fmtlist=&fmtlist,cntlout=&base_fmts)
|
|
140
140
|
|
|
@@ -144,8 +144,11 @@ select distinct fmtname into: fmtlist separated by ' ' from &libds;
|
|
|
144
144
|
*/
|
|
145
145
|
%mddl_sas_cntlout(libds=&template)
|
|
146
146
|
data &inlibds;
|
|
147
|
+
length &delete_col $3;
|
|
147
148
|
if 0 then set &template;
|
|
148
149
|
set &libds;
|
|
150
|
+
if &delete_col='' then &delete_col='No';
|
|
151
|
+
fmtname=upcase(fmtname);
|
|
149
152
|
if missing(type) then do;
|
|
150
153
|
if substr(fmtname,1,1)='$' then type='C';
|
|
151
154
|
else type='N';
|
|
@@ -156,7 +159,6 @@ data &inlibds;
|
|
|
156
159
|
end;
|
|
157
160
|
run;
|
|
158
161
|
|
|
159
|
-
|
|
160
162
|
/**
|
|
161
163
|
* Identify new records
|
|
162
164
|
*/
|
|
@@ -263,7 +265,7 @@ options ibufsize=&ibufsize;
|
|
|
263
265
|
%end;
|
|
264
266
|
|
|
265
267
|
%mp_storediffs(&libcat-FC
|
|
266
|
-
,&
|
|
268
|
+
,&base_fmts
|
|
267
269
|
,FMTNAME START
|
|
268
270
|
,delds=&outds_del
|
|
269
271
|
,modds=&outds_mod
|
package/meta/mm_spkexport.sas
CHANGED
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
%let platform_object_path=%mf_loc(POF);
|
|
103
103
|
%let ds=%mf_getuniquename(prefix=spkexportable);
|
|
104
104
|
|
|
105
|
-
%mm_tree(root=%str(&metaloc)
|
|
105
|
+
%mm_tree(root=%str(&metaloc),types=EXPORTABLE ,outds=&ds)
|
|
106
106
|
|
|
107
107
|
%if %mf_isblank(&outref)=1 %then %let outref=%mf_getuniquefileref();
|
|
108
108
|
|
|
@@ -111,19 +111,27 @@ data _null_;
|
|
|
111
111
|
file &outref lrecl=32767;
|
|
112
112
|
length str $32767;
|
|
113
113
|
if _n_=1 then do;
|
|
114
|
+
put "# Script generated by &sysuserid on %sysfunc(datetime(),datetime19.)";
|
|
114
115
|
put "cd ""&platform_object_path"" \";
|
|
115
116
|
put "; ./ExportPackage -host &host -port &port -user &mmxuser \";
|
|
116
|
-
put " -disableX11 -password &mmxpass \"
|
|
117
|
+
put " -disableX11 -password &mmxpass \";
|
|
117
118
|
put " -package ""&cmdoutloc/&cmdoutname..spk"" \";
|
|
118
119
|
end;
|
|
119
120
|
/* exclude particular patterns from the exported SPK */
|
|
120
121
|
%if "&excludevars" ne "0" %then %do;
|
|
121
|
-
/* ignore top level folder else all subcontent will be exported regardless */
|
|
122
|
-
if _n_>1;
|
|
123
122
|
%do i=1 %to %sysfunc(countw(&excludevars));
|
|
124
123
|
%let var=%scan(&excludevars,&i);
|
|
125
|
-
if
|
|
124
|
+
if _n_=1 then do;
|
|
125
|
+
length excludestr&i $1000;
|
|
126
|
+
retain excludestr&i;
|
|
127
|
+
excludestr&i=symget("&var");
|
|
128
|
+
putlog excludestr&i=;
|
|
129
|
+
putlog path=;
|
|
130
|
+
end;
|
|
131
|
+
if index(path,cats(excludestr&i))=0 and index(name,cats(excludestr&i))=0;
|
|
126
132
|
%end;
|
|
133
|
+
/* ignore top level folder else all subcontent will be exported regardless */
|
|
134
|
+
if _n_>1;
|
|
127
135
|
%end;
|
|
128
136
|
str=' -objects '!!cats('"',path,'/',name,"(",publictype,')" \');
|
|
129
137
|
put str;
|
package/package.json
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
@file
|
|
3
|
+
@brief Deletes a file from SASjs Drive
|
|
4
|
+
@details Deletes a file from SASjs Drive, if it exists.
|
|
5
|
+
|
|
6
|
+
Example:
|
|
7
|
+
|
|
8
|
+
filename stpcode temp;
|
|
9
|
+
data _null_;
|
|
10
|
+
file stpcode;
|
|
11
|
+
put '%put hello world;';
|
|
12
|
+
run;
|
|
13
|
+
%ms_createfile(/some/stored/program.sas, inref=stpcode)
|
|
14
|
+
|
|
15
|
+
%ms_deletefile(/some/stored/program.sas)
|
|
16
|
+
|
|
17
|
+
@param [in] driveloc The full path to the file in SASjs Drive
|
|
18
|
+
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
**/
|
|
22
|
+
|
|
23
|
+
%macro ms_deletefile(driveloc
|
|
24
|
+
,mdebug=0
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
proc http method='DELETE'
|
|
28
|
+
url="&_sasjs_apiserverurl/SASjsApi/drive/file?_filePath=&driveloc";
|
|
29
|
+
%if &mdebug=1 %then %do;
|
|
30
|
+
debug level=2;
|
|
31
|
+
%end;
|
|
32
|
+
run;
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
%mend ms_deletefile;
|
package/server/ms_getfile.sas
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
filename &outref temp;
|
|
23
23
|
|
|
24
24
|
proc http method='GET' out=&outref
|
|
25
|
-
url="&_sasjs_apiserverurl/SASjsApi/drive/file?
|
|
25
|
+
url="&_sasjs_apiserverurl/SASjsApi/drive/file?_filePath=&driveloc";
|
|
26
26
|
%if &mdebug=1 %then %do;
|
|
27
27
|
debug level=2;
|
|
28
28
|
%end;
|