@sasjs/core 2.49.0 → 2.52.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
@@ -189,7 +189,7 @@ If you find this library useful, please leave a [star](https://github.com/sasjs/
189
189
 
190
190
  ## Contributors ✨
191
191
  <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
192
- [![All Contributors](https://img.shields.io/badge/all_contributors-9-orange.svg?style=flat-square)](#contributors-)
192
+ [![All Contributors](https://img.shields.io/badge/all_contributors-10-orange.svg?style=flat-square)](#contributors-)
193
193
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
194
194
  Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
195
195
 
@@ -209,6 +209,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
209
209
  <tr>
210
210
  <td align="center"><a href="https://github.com/kkchandok"><img src="https://avatars.githubusercontent.com/u/46090627?v=4?s=100" width="100px;" alt=""/><br /><sub><b>kkchandok</b></sub></a><br /><a href="#ideas-kkchandok" title="Ideas, Planning, & Feedback">🤔</a></td>
211
211
  <td align="center"><a href="https://github.com/VladislavParhomchik"><img src="https://avatars.githubusercontent.com/u/83717836?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vladislav Parhomchik</b></sub></a><br /><a href="https://github.com/sasjs/core/commits?author=VladislavParhomchik" title="Tests">⚠️</a> <a href="https://github.com/sasjs/core/pulls?q=is%3Apr+reviewed-by%3AVladislavParhomchik" title="Reviewed Pull Requests">👀</a></td>
212
+ <td align="center"><a href="https://github.com/vznesh"><img src="https://avatars.githubusercontent.com/u/28916792?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vignesh T.</b></sub></a><br /><a href="https://github.com/sasjs/core/issues?q=author%3Avznesh" title="Bug reports">🐛</a></td>
212
213
  </tr>
213
214
  </table>
214
215
 
@@ -0,0 +1,69 @@
1
+ /**
2
+ @file
3
+ @brief A macro to delete a directory
4
+ @details Will delete all folder content (including subfolder content) and
5
+ finally, the folder itself.
6
+
7
+ Usage:
8
+
9
+ %let rootdir=%sysfunc(pathname(work))/demo;
10
+ %mf_mkdir(&rootdir)
11
+ %mf_mkdir(&rootdir/subdir)
12
+ %mf_mkdir(&rootdir/subdir/subsubdir)
13
+ data "&rootdir/subdir/example.sas7bdat";
14
+ run;
15
+
16
+ %mp_deletefolder(&rootdir)
17
+
18
+ @param path Unquoted path to the folder to delete.
19
+
20
+ <h4> SAS Macros </h4>
21
+ @li mf_getuniquename.sas
22
+ @li mf_isdir.sas
23
+ @li mp_dirlist.sas
24
+
25
+ <h4> Related Macros </h4>
26
+ @li mp_deletefolder.test.sas
27
+
28
+ **/
29
+
30
+ %macro mp_deletefolder(folder);
31
+ /* proceed if valid directory */
32
+ %if %mf_isdir(&folder)=1 %then %do;
33
+
34
+ /* prep temp table */
35
+ %local tempds;
36
+ %let tempds=%mf_getuniquename();
37
+
38
+ /* recursive directory listing */
39
+ %mp_dirlist(path=&folder,outds=work.&tempds, maxdepth=MAX)
40
+
41
+ /* sort descending level so can delete folder contents before folders */
42
+ proc sort data=work.&tempds;
43
+ by descending level;
44
+ run;
45
+
46
+ /* ensure top level folder is removed at the end */
47
+ proc sql;
48
+ insert into work.&tempds set filepath="&folder";
49
+
50
+ /* delete everything */
51
+ data _null_;
52
+ set work.&tempds end=last;
53
+ length fref $8;
54
+ rc=filename(fref,filepath);
55
+ rc=fdelete(fref);
56
+ if rc then do;
57
+ msg=sysmsg();
58
+ put "&sysmacroname:" / rc= / msg= / filepath=;
59
+ end;
60
+ rc=filename(fref);
61
+ run;
62
+
63
+ /* tidy up */
64
+ proc sql;
65
+ drop table work.&tempds;
66
+
67
+ %end;
68
+ %else %put &sysmacroname: &folder: is not a valid / accessible folder. ;
69
+ %mend mp_deletefolder;
@@ -3,20 +3,13 @@
3
3
  @brief Returns all files and subdirectories within a specified parent
4
4
  @details When used with getattrs=NO, is not OS specific (uses dopen / dread).
5
5
 
6
- If getattrs=YES then the doptname / foptname functions are used to scan all
7
- properties - any characters that are not valid in a SAS name (v7) are simply
8
- stripped, and the table is transposed so theat each property is a column
9
- and there is one file per row. An attempt is made to get all properties
10
- whether a file or folder, but some files/folders cannot be accessed, and so
11
- not all properties can / will be populated.
12
-
13
6
  Credit for the rename approach:
14
7
  https://communities.sas.com/t5/SAS-Programming/SAS-Function-to-convert-string-to-Legal-SAS-Name/m-p/27375/highlight/true#M5003
15
8
 
16
9
 
17
10
  usage:
18
11
 
19
- %mp_dirlist(path=/some/location,outds=myTable)
12
+ %mp_dirlist(path=/some/location, outds=myTable, maxdepth=MAX)
20
13
 
21
14
  %mp_dirlist(outds=cwdfileprops, getattrs=YES)
22
15
 
@@ -30,11 +23,19 @@
30
23
  X CMD) do please raise an issue!
31
24
 
32
25
 
33
- @param path= for which to return contents
34
- @param fref= Provide a DISK engine fileref as an alternative to PATH
35
- @param outds= the output dataset to create
36
- @param getattrs= YES/NO (default=NO). Uses doptname and foptname to return
37
- all attributes for each file / folder.
26
+ @param [in] path= for which to return contents
27
+ @param [in] fref= Provide a DISK engine fileref as an alternative to PATH
28
+ @param [in] maxdepth= (0) Set to a positive integer to indicate the level of
29
+ subdirectory scan recursion - eg 3, to go `./3/levels/deep`. For unlimited
30
+ recursion, set to MAX.
31
+ @param [out] outds= the output dataset to create
32
+ @param [out] getattrs= (NO) If getattrs=YES then the doptname / foptname
33
+ functions are used to scan all properties - any characters that are not
34
+ valid in a SAS name (v7) are simply stripped, and the table is transposed
35
+ so theat each property is a column and there is one file per row. An
36
+ attempt is made to get all properties whether a file or folder, but some
37
+ files/folders cannot be accessed, and so not all properties can / will be
38
+ populated.
38
39
 
39
40
 
40
41
  @returns outds contains the following variables:
@@ -44,8 +45,15 @@
44
45
  - filename (just the file name)
45
46
  - ext (.extension)
46
47
  - msg (system message if any issues)
48
+ - level (depth of folder)
47
49
  - OS SPECIFIC variables, if <code>getattrs=</code> is used.
48
50
 
51
+ <h4> SAS Macros </h4>
52
+ @li mp_dropmembers.sas
53
+
54
+ <h4> Related Macros </h4>
55
+ @li mp_dirlist.test.sas
56
+
49
57
  @version 9.2
50
58
  @author Allan Bowe
51
59
  **/
@@ -54,14 +62,27 @@
54
62
  , fref=0
55
63
  , outds=work.mp_dirlist
56
64
  , getattrs=NO
65
+ , maxdepth=0
66
+ , level=0 /* The level of recursion to perform. For internal use only. */
57
67
  )/*/STORE SOURCE*/;
58
68
  %let getattrs=%upcase(&getattrs)XX;
59
69
 
60
- data &outds(compress=no
61
- keep=file_or_folder filepath filename ext msg directory
70
+ /* temp table */
71
+ %local out_ds;
72
+ data;run;
73
+ %let out_ds=%str(&syslast);
74
+
75
+ /* drop main (top) table if it exists */
76
+ %if &level=0 %then %do;
77
+ %mp_dropmembers(%scan(&outds,-1,.), libref=WORK)
78
+ %end;
79
+
80
+ data &out_ds(compress=no
81
+ keep=file_or_folder filepath filename ext msg directory level
62
82
  );
63
83
  length directory filepath $500 fref fref2 $8 file_or_folder $6 filename $80
64
84
  ext $20 msg $200;
85
+ retain level &level;
65
86
  %if &fref=0 %then %do;
66
87
  rc = filename(fref, "&path");
67
88
  %end;
@@ -119,8 +140,8 @@ data &outds(compress=no
119
140
  run;
120
141
 
121
142
  %if %substr(&getattrs,1,1)=Y %then %do;
122
- data &outds;
123
- set &outds;
143
+ data &out_ds;
144
+ set &out_ds;
124
145
  length infoname infoval $60 fref $8;
125
146
  rc=filename(fref,filepath);
126
147
  drop rc infoname fid i close fref;
@@ -161,10 +182,35 @@ run;
161
182
  run;
162
183
  proc sort;
163
184
  by filepath sasname;
164
- proc transpose data=&outds out=&outds(drop=_:);
185
+ proc transpose data=&out_ds out=&out_ds(drop=_:);
165
186
  id sasname;
166
187
  var infoval;
167
188
  by filepath file_or_folder filename ext ;
168
189
  run;
169
190
  %end;
191
+
192
+ data &out_ds;
193
+ set &out_ds(where=(filepath ne ''));
194
+ run;
195
+
196
+ /* update main table */
197
+ proc append base=&outds data=&out_ds;
198
+ run;
199
+
200
+ /* recursive call */
201
+ %if &maxdepth>&level or &maxdepth=MAX %then %do;
202
+ data _null_;
203
+ set &out_ds;
204
+ where file_or_folder='folder';
205
+ code=cats('%nrstr(%mp_dirlist(path=',filepath,",outds=&outds"
206
+ ,",getattrs=&getattrs,level=%eval(&level+1),maxdepth=&maxdepth))");
207
+ put code=;
208
+ call execute(code);
209
+ run;
210
+ %end;
211
+
212
+ /* tidy up */
213
+ proc sql;
214
+ drop table &out_ds;
215
+
170
216
  %mend mp_dirlist;
@@ -0,0 +1,255 @@
1
+ /**
2
+ @file
3
+ @brief Mechanism for locking tables to prevent parallel modifications
4
+ @details Uses a control table to enable ANY table to be locked for updates.
5
+ Only useful if every update uses the macro! Used heavily within
6
+ [Data Controller for SAS](https://datacontroller.io).
7
+
8
+ The underlying table is structured as per the MAKETABLE action.
9
+
10
+ @param [in] action The action to be performed. Valid values:
11
+ @li LOCK - Sets the lock flag, also confirms if a SAS lock is available
12
+ @li UNLOCK - Unlocks the table
13
+ @li MAKETABLE - creates the control table (ctl_ds)
14
+ @param [in] lib= (WORK) The libref of the table to lock. Should already be
15
+ assigned.
16
+ @param [in] ds= The dataset to lock
17
+ @param [in] ref= A meaningful reference to enable the lock to be traced. Max
18
+ length is 200 characters.
19
+ @param [out] ctl_ds= (0) The control table which controls the actual locking.
20
+ Should already be assigned and available.
21
+ @param [in] loops= (25) Number of times to check for a lock.
22
+ @param [in] loop_secs= (1) Seconds to wait between each lock attempt
23
+
24
+ <h4> SAS Macros </h4>
25
+ @li mp_abort.sas
26
+ @li mp_lockfilecheck.sas
27
+ @li mf_getuser.sas
28
+
29
+ <h4> Related Macros </h4>
30
+ @li mp_lockanytable.test.sas
31
+
32
+ @version 9.2
33
+
34
+ **/
35
+
36
+ %macro mp_lockanytable(
37
+ action
38
+ ,lib= WORK
39
+ ,ds=0
40
+ ,ref=
41
+ ,ctl_ds=0
42
+ ,loops=25
43
+ ,loop_secs=1
44
+ );
45
+ data _null_;
46
+ if _n_=1 then putlog "&sysmacroname entry vars:";
47
+ set sashelp.vmacro;
48
+ where scope="&sysmacroname";
49
+ put name '=' value;
50
+ run;
51
+
52
+ %mp_abort(iftrue= (&ds=0 and &action ne MAKETABLE)
53
+ ,mac=&sysmacroname
54
+ ,msg=%str(dataset was not provided)
55
+ )
56
+ %mp_abort(iftrue= (&ctl_ds=0)
57
+ ,mac=&sysmacroname
58
+ ,msg=%str(Control dataset was not provided)
59
+ )
60
+
61
+ /* set up lib & mac vars */
62
+ %let lib=%upcase(&lib);
63
+ %let ds=%upcase(&ds);
64
+ %let action=%upcase(&action);
65
+ %local user x trans msg abortme;
66
+ %let user=%mf_getuser();
67
+ %let abortme=0;
68
+
69
+ %mp_abort(iftrue= (&action ne LOCK & &action ne UNLOCK & &action ne MAKETABLE)
70
+ ,mac=&sysmacroname
71
+ ,msg=%str(Invalid action (&action) provided)
72
+ )
73
+
74
+ /* if an err condition exists, exit before we even begin */
75
+ %mp_abort(iftrue= (&syscc>0 and &action=LOCK)
76
+ ,mac=&sysmacroname
77
+ ,msg=%str(aborting due to syscc=&syscc on LOCK entry)
78
+ )
79
+
80
+ /* do not bother locking work tables (else may affect all WORK libraries) */
81
+ %if (%upcase(&lib)=WORK or %str(&lib)=%str()) & &action ne MAKETABLE %then %do;
82
+ %put NOTE: WORK libraries will not be registered in the locking system.;
83
+ %return;
84
+ %end;
85
+
86
+ /* do not proceed if no observations can be processed */
87
+ %mp_abort(iftrue= (%sysfunc(getoption(OBS))=0)
88
+ ,mac=&sysmacroname
89
+ ,msg=%str(options obs = 0. syserrortext=&syserrortext)
90
+ )
91
+
92
+ %if &ACTION=LOCK %then %do;
93
+
94
+ /* abort if a SAS lock is already in place, or cannot be applied */
95
+ %mp_lockfilecheck(&lib..&ds)
96
+
97
+ /* next, check there is a record for this table */
98
+ %local record_exists_check;
99
+ proc sql noprint;
100
+ select count(*) into: record_exists_check from &ctl_ds
101
+ where LOCK_LIB ="&lib" and LOCK_DS="&ds";
102
+ quit;
103
+ %if &syscc>0 %then %put syscc=&syscc sqlrc=&sqlrc;
104
+ %if &record_exists_check=0 %then %do;
105
+ data _null_;
106
+ putlog "&sysmacroname: adding record to lock table..";
107
+ run;
108
+
109
+ data ;
110
+ if 0 then set &ctl_ds;
111
+ LOCK_LIB ="&lib";
112
+ LOCK_DS="&ds";
113
+ LOCK_STATUS_CD='LOCKED';
114
+ LOCK_START_DTTM="%sysfunc(datetime(),E8601DT26.6)"dt;
115
+ LOCK_USER_NM="&user";
116
+ LOCK_PID="&sysjobid";
117
+ LOCK_REF="&ref";
118
+ output;stop;
119
+ run;
120
+ %let trans=&syslast;
121
+ proc append base=&ctl_ds data=&trans;
122
+ run;
123
+ %end;
124
+ /* if record does exist, perform lock attempts */
125
+ %else %do x=1 %to &loops;
126
+ data _null_;
127
+ putlog "&sysmacroname: attempting lock (iteration &x) "@;
128
+ putlog "at %sysfunc(datetime(),datetime19.) ..";
129
+ run;
130
+
131
+ proc sql;
132
+ update &ctl_ds
133
+ set LOCK_STATUS_CD='LOCKED'
134
+ , LOCK_START_DTTM="%sysfunc(datetime(),E8601DT26.6)"dt
135
+ , LOCK_USER_NM="&user"
136
+ , LOCK_PID="&sysjobid"
137
+ , LOCK_REF="&ref"
138
+ where LOCK_LIB ="&lib" and LOCK_DS="&ds";
139
+ quit;
140
+ /**
141
+ * NOTE - occasionally SQL server will return an err code (deadlocked
142
+ * transaction). If so, ignore it, keep calm, and carry on..
143
+ */
144
+ %if &syscc>0 %then %do;
145
+ data _null_;
146
+ putlog 'NOTE-' / 'NOTE-';
147
+ putlog "NOTE- &sysmacroname: Update failed. "@;
148
+ putlog "Resetting err conditions and re-attempting.";
149
+ putlog "NOTE- syscc=&syscc syserr=&syserr sqlrc=&sqlrc";
150
+ putlog 'NOTE-' / 'NOTE-';
151
+ run;
152
+ %let syscc=0;
153
+ %let sqlrc=0;
154
+ %end;
155
+
156
+ /* now check if the record was successfully updated */
157
+ %local success_check;
158
+ proc sql noprint;
159
+ select count(*) into: success_check from &ctl_ds
160
+ where LOCK_LIB ="&lib" and LOCK_DS="&ds"
161
+ and LOCK_PID="&sysjobid" and LOCK_STATUS_CD='LOCKED';
162
+ quit;
163
+ %if &success_check=0 %then %do;
164
+ %if &x < &loops %then %do;
165
+ /* pause before next check */
166
+ data _null_;
167
+ putlog 'NOTE-' / 'NOTE-';
168
+ putlog "NOTE- &sysmacroname: table locked, waiting "@;
169
+ putlog "%sysfunc(sleep(&loop_inc)) seconds.. ";
170
+ putlog "NOTE- (iteration &x of &loops)";
171
+ putlog 'NOTE-' / 'NOTE-';
172
+ run;
173
+ %end;
174
+ %else %do;
175
+ %let msg=Unable to lock &lib..&ds via &ctl_ds after &loops attempts.\n
176
+ Please ask your administrator to investigate!;
177
+ %let abortme=1;
178
+ %end;
179
+ %end;
180
+ %else %do;
181
+ data _null_;
182
+ putlog 'NOTE-' / 'NOTE-';
183
+ putlog "NOTE- &sysmacroname: Table &lib..&ds locked at "@
184
+ putlog " %sysfunc(datetime(),datetime19.) (iteration &x)"@;
185
+ putlog 'NOTE-' / 'NOTE-';
186
+ run;
187
+ %if &syscc>0 %then %do;
188
+ %put setting syscc(&syscc) back to 0;
189
+ %let syscc=0;
190
+ %end;
191
+ %let x=&loops; /* no more iterations needed */
192
+ %end;
193
+ %end;
194
+ %end;
195
+ %else %if &ACTION=UNLOCK %then %do;
196
+ %local status;
197
+ proc sql noprint;
198
+ select LOCK_STATUS_CD into: status from &ctl_ds
199
+ where LOCK_LIB ="&lib" and LOCK_DS="&ds";
200
+ quit;
201
+ %if &syscc>0 %then %put syscc=&syscc sqlrc=&sqlrc;
202
+ %if &status=LOCKED %then %do;
203
+ data _null_;
204
+ putlog "&sysmacroname: unlocking &lib..&ds:";
205
+ run;
206
+ proc sql;
207
+ update &ctl_ds
208
+ set LOCK_STATUS_CD='UNLOCKED'
209
+ , LOCK_END_DTTM="%sysfunc(datetime(),E8601DT26.6)"dt
210
+ , LOCK_USER_NM="&user"
211
+ , LOCK_PID="&sysjobid"
212
+ , LOCK_REF="&ref"
213
+ where LOCK_LIB ="&lib" and LOCK_DS="&ds";
214
+ quit;
215
+ %end;
216
+ %else %if &status=UNLOCKED %then %do;
217
+ %put %str(WAR)NING: &lib..&ds is already unlocked!;
218
+ %end;
219
+ %else %do;
220
+ %put NOTE: Unrecognised STATUS_CD (&status) in &ctl_ds;
221
+ %let abortme=1;
222
+ %end;
223
+ %end;
224
+ %else %if &action=MAKETABLE %then %do;
225
+ proc sql;
226
+ create table &ctl_ds(
227
+ lock_lib char(8),
228
+ lock_ds char(32),
229
+ lock_status_cd char(10) not null,
230
+ lock_user_nm char(100) not null ,
231
+ lock_ref char(200),
232
+ lock_pid char(10),
233
+ lock_start_dttm num format=E8601DT26.6,
234
+ lock_end_dttm num format=E8601DT26.6,
235
+ constraint pk_mp_lockanytable primary key(lock_lib,lock_ds));
236
+ %end;
237
+ %else %do;
238
+ %let msg=lock_anytable given unsupported action (&action);
239
+ %let abortme=1;
240
+ %end;
241
+
242
+ /* catch errors - mp_abort must be called outside of a logic block */
243
+ %mp_abort(iftrue=(&abortme=1),
244
+ msg=%superq(msg),
245
+ mac=&sysmacroname
246
+ )
247
+
248
+ %exit_macro:
249
+ data _null_;
250
+ put "&sysmacroname: Exit vars: action=&action lib=&lib ds=&ds";
251
+ put " syscc=&syscc sqlrc=&sqlrc syserr=&syserr";
252
+ run;
253
+ %mend mp_lockanytable;
254
+
255
+
@@ -0,0 +1,97 @@
1
+ /**
2
+ @file
3
+ @brief Aborts if a SAS lock file is in place, or if one cannot be applied.
4
+ @details Used in conjuction with the mp_lockanytable macro.
5
+ More info here: https://sasensei.com/flash/24
6
+
7
+ Usage:
8
+
9
+ data work.test; a=1;run;
10
+ %mp_lockfilecheck(work.test)
11
+
12
+ @param [in] libds The libref.dataset for which to check the lock status
13
+
14
+ <h4> SAS Macros </h4>
15
+ @li mp_abort.sas
16
+ @li mf_getattrc.sas
17
+
18
+ <h4> Related Macros </h4>
19
+ @li mp_lockanytable.sas
20
+ @li mp_lockfilecheck.test.sas
21
+
22
+ @version 9.2
23
+ **/
24
+
25
+ %macro mp_lockfilecheck(
26
+ libds
27
+ )/*/STORE SOURCE*/;
28
+
29
+ data _null_;
30
+ if _n_=1 then putlog "&sysmacroname entry vars:";
31
+ set sashelp.vmacro;
32
+ where scope="&sysmacroname";
33
+ put name '=' value;
34
+ run;
35
+
36
+ %mp_abort(iftrue= (&syscc>0)
37
+ ,mac=checklock.sas
38
+ ,msg=Aborting with syscc=&syscc on entry.
39
+ )
40
+ %mp_abort(iftrue= (&libds=0)
41
+ ,mac=&sysmacroname
42
+ ,msg=%str(libds not provided)
43
+ )
44
+
45
+ %local msg lib ds;
46
+ %let lib=%upcase(%scan(&libds,1,.));
47
+ %let ds=%upcase(%scan(&libds,2,.));
48
+
49
+ /* do not proceed if no observations can be processed */
50
+ %let msg=options obs = 0. syserrortext=%superq(syserrortext);
51
+ %mp_abort(iftrue= (%sysfunc(getoption(OBS))=0)
52
+ ,mac=checklock.sas
53
+ ,msg=%superq(msg)
54
+ )
55
+
56
+ data _null_;
57
+ putlog "Checking engine & member type";
58
+ run;
59
+ %local engine memtype;
60
+ %let memtype=%mf_getattrc(&libds,MTYPE);
61
+ %let engine=%mf_getattrc(&libds,ENGINE);
62
+
63
+ %if &engine ne V9 and &engine ne BASE %then %do;
64
+ data _null_;
65
+ putlog "Lib &lib is not assigned using BASE engine - uses &engine instead";
66
+ putlog "SAS lock check will not be performed";
67
+ run;
68
+ %return;
69
+ %end;
70
+ %else %if &memtype ne DATA %then %do;
71
+ %put NOTE: Cannot lock a VIEW!! Memtype=&memtype;
72
+ %return;
73
+ %end;
74
+
75
+ data _null_;
76
+ putlog "Engine = &engine, memtype=&memtype";
77
+ putlog "Attempting lock statement";
78
+ run;
79
+
80
+ lock &libds;
81
+
82
+ %local abortme;
83
+ %let abortme=0;
84
+ %if &syscc>0 or &SYSLCKRC ne 0 %then %do;
85
+ %let msg=Unable to apply lock on &libds (SYSLCKRC=&SYSLCKRC syscc=&syscc);
86
+ %put %str(ERR)OR: &sysmacroname: &msg;
87
+ %let abortme=1;
88
+ %end;
89
+
90
+ lock &libds clear;
91
+
92
+ %mp_abort(iftrue= (&abortme=1)
93
+ ,mac=&sysmacroname
94
+ ,msg=%superq(msg)
95
+ )
96
+
97
+ %mend mp_lockfilecheck;
package/base/mp_zip.sas CHANGED
@@ -16,11 +16,18 @@
16
16
  @li mp_dirlist.sas
17
17
 
18
18
  @param in= unquoted filepath, dataset of files or directory to zip
19
- @param type= FILE, DATASET, DIRECTORY. (FILE / DATASET not ready yet)
20
- @param outname= output file to create, without .zip extension
21
- @param outpath= location for output zip file
19
+ @param type= (FILE) Valid values:
20
+ @li FILE - /full/path/and/filename.extension to a particular file
21
+ @li DATASET - a dataset containing a list of files to zip (see `incol`)
22
+ @li DIRECTORY - a directory to zip
23
+ @param outname= (FILE) Output file to create, _without_ .zip extension
24
+ @param outpath= (%sysfunc(pathname(WORK))) Parent folder for output zip file
22
25
  @param incol= if DATASET input, say which column contains the filepath
23
26
 
27
+ <h4> Related Macros </h4>
28
+ @li mp_unzip.sas
29
+ @li mp_zip.test.sas
30
+
24
31
  @version 9.2
25
32
  @author Allan Bowe
26
33
  @source https://github.com/sasjs/core
@@ -51,9 +58,9 @@ ods package open nopf;
51
58
  set &ds;
52
59
  length __command $4000;
53
60
  if file_or_folder='file';
54
- command=cats('ods package add file="',filepath
61
+ __command=cats('ods package add file="',filepath
55
62
  ,'" mimetype="application/x-compress";');
56
- call execute(command);
63
+ call execute(__command);
57
64
  run;
58
65
  /* tidy up */
59
66
  %if &debug=NO %then %do;
@@ -64,11 +71,10 @@ ods package open nopf;
64
71
  data _null_;
65
72
  set &in;
66
73
  length __command $4000;
67
- command=cats('ods package add file="',&incol
74
+ __command=cats('ods package add file="',&incol
68
75
  ,'" mimetype="application/x-compress";');
69
- call execute(command);
76
+ call execute(__command);
70
77
  run;
71
- ods package add file="&in" mimetype="application/x-compress";
72
78
  %end;
73
79
 
74
80
 
package/package.json CHANGED
@@ -35,5 +35,5 @@
35
35
  "devDependencies": {
36
36
  "@sasjs/cli": "^2.39.0"
37
37
  },
38
- "version": "2.49.0"
38
+ "version": "2.52.0"
39
39
  }