@sasjs/core 3.9.1 → 3.9.2
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/base/mp_dirlist.sas +25 -9
- package/package.json +1 -1
package/base/mp_dirlist.sas
CHANGED
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
Credit for the rename approach:
|
|
7
7
|
https://communities.sas.com/t5/SAS-Programming/SAS-Function-to-convert-string-to-Legal-SAS-Name/m-p/27375/highlight/true#M5003
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
usage:
|
|
9
|
+
Usage:
|
|
11
10
|
|
|
12
11
|
%mp_dirlist(path=/some/location, outds=myTable, maxdepth=MAX)
|
|
13
12
|
|
|
@@ -23,12 +22,12 @@
|
|
|
23
22
|
X CMD) do please raise an issue!
|
|
24
23
|
|
|
25
24
|
|
|
26
|
-
@param [in] path= for which to return contents
|
|
27
|
-
@param [in] fref= Provide a DISK engine fileref as an alternative to PATH
|
|
25
|
+
@param [in] path= (%sysfunc(pathname(work))) Path for which to return contents
|
|
26
|
+
@param [in] fref= (0) Provide a DISK engine fileref as an alternative to PATH
|
|
28
27
|
@param [in] maxdepth= (0) Set to a positive integer to indicate the level of
|
|
29
28
|
subdirectory scan recursion - eg 3, to go `./3/levels/deep`. For unlimited
|
|
30
29
|
recursion, set to MAX.
|
|
31
|
-
@param [out] outds=
|
|
30
|
+
@param [out] outds= (work.mp_dirlist) The output dataset to create
|
|
32
31
|
@param [out] getattrs= (NO) If getattrs=YES then the doptname / foptname
|
|
33
32
|
functions are used to scan all properties - any characters that are not
|
|
34
33
|
valid in a SAS name (v7) are simply stripped, and the table is transposed
|
|
@@ -49,13 +48,15 @@
|
|
|
49
48
|
- OS SPECIFIC variables, if <code>getattrs=</code> is used.
|
|
50
49
|
|
|
51
50
|
<h4> SAS Macros </h4>
|
|
51
|
+
@li mf_existds.sas
|
|
52
|
+
@li mf_getvarlist.sas
|
|
53
|
+
@li mf_wordsinstr1butnotstr2.sas
|
|
52
54
|
@li mp_dropmembers.sas
|
|
53
55
|
|
|
54
56
|
<h4> Related Macros </h4>
|
|
55
57
|
@li mp_dirlist.test.sas
|
|
56
58
|
|
|
57
59
|
@version 9.2
|
|
58
|
-
@author Allan Bowe
|
|
59
60
|
**/
|
|
60
61
|
|
|
61
62
|
%macro mp_dirlist(path=%sysfunc(pathname(work))
|
|
@@ -193,9 +194,24 @@ data &out_ds;
|
|
|
193
194
|
set &out_ds(where=(filepath ne ''));
|
|
194
195
|
run;
|
|
195
196
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
197
|
+
/**
|
|
198
|
+
* The above transpose can mean that some updates create additional columns.
|
|
199
|
+
* This necessitates the occasional use of datastep over proc append.
|
|
200
|
+
*/
|
|
201
|
+
%local basevars appvars usedatastep;
|
|
202
|
+
%let basevars=%mf_getvarlist(&outds);
|
|
203
|
+
%let appvars=%mf_getvarlist(&out_ds);
|
|
204
|
+
%let newvars=%length(%mf_wordsinstr1butnotstr2(Str1=&appvars,Str2=&basevars));
|
|
205
|
+
|
|
206
|
+
%if %mf_existds(&outds) and &newvars>0 %then %do;
|
|
207
|
+
data &outds;
|
|
208
|
+
set &outds &out_ds;
|
|
209
|
+
run;
|
|
210
|
+
%end;
|
|
211
|
+
%else %do;
|
|
212
|
+
proc append base=&outds data=&out_ds force nowarn;
|
|
213
|
+
run;
|
|
214
|
+
%end;
|
|
199
215
|
|
|
200
216
|
/* recursive call */
|
|
201
217
|
%if &maxdepth>&level or &maxdepth=MAX %then %do;
|
package/package.json
CHANGED