mirror of
https://github.com/sasjs/core.git
synced 2026-01-05 00:20:05 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8cfa37ce8b | ||
|
|
351ceeb357 | ||
|
|
259bcc0173 | ||
|
|
db195a8311 | ||
|
|
4307bfb1b5 |
46
all.sas
46
all.sas
@@ -3863,8 +3863,7 @@ run;
|
|||||||
Credit for the rename approach:
|
Credit for the rename approach:
|
||||||
https://communities.sas.com/t5/SAS-Programming/SAS-Function-to-convert-string-to-Legal-SAS-Name/m-p/27375/highlight/true#M5003
|
https://communities.sas.com/t5/SAS-Programming/SAS-Function-to-convert-string-to-Legal-SAS-Name/m-p/27375/highlight/true#M5003
|
||||||
|
|
||||||
|
Usage:
|
||||||
usage:
|
|
||||||
|
|
||||||
%mp_dirlist(path=/some/location, outds=myTable, maxdepth=MAX)
|
%mp_dirlist(path=/some/location, outds=myTable, maxdepth=MAX)
|
||||||
|
|
||||||
@@ -3880,12 +3879,12 @@ run;
|
|||||||
X CMD) do please raise an issue!
|
X CMD) do please raise an issue!
|
||||||
|
|
||||||
|
|
||||||
@param [in] path= for which to return contents
|
@param [in] path= (%sysfunc(pathname(work))) Path for which to return contents
|
||||||
@param [in] fref= Provide a DISK engine fileref as an alternative to PATH
|
@param [in] fref= (0) Provide a DISK engine fileref as an alternative to PATH
|
||||||
@param [in] maxdepth= (0) Set to a positive integer to indicate the level of
|
@param [in] maxdepth= (0) Set to a positive integer to indicate the level of
|
||||||
subdirectory scan recursion - eg 3, to go `./3/levels/deep`. For unlimited
|
subdirectory scan recursion - eg 3, to go `./3/levels/deep`. For unlimited
|
||||||
recursion, set to MAX.
|
recursion, set to MAX.
|
||||||
@param [out] outds= the output dataset to create
|
@param [out] outds= (work.mp_dirlist) The output dataset to create
|
||||||
@param [out] getattrs= (NO) If getattrs=YES then the doptname / foptname
|
@param [out] getattrs= (NO) If getattrs=YES then the doptname / foptname
|
||||||
functions are used to scan all properties - any characters that are not
|
functions are used to scan all properties - any characters that are not
|
||||||
valid in a SAS name (v7) are simply stripped, and the table is transposed
|
valid in a SAS name (v7) are simply stripped, and the table is transposed
|
||||||
@@ -3906,13 +3905,15 @@ run;
|
|||||||
- OS SPECIFIC variables, if <code>getattrs=</code> is used.
|
- OS SPECIFIC variables, if <code>getattrs=</code> is used.
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_existds.sas
|
||||||
|
@li mf_getvarlist.sas
|
||||||
|
@li mf_wordsinstr1butnotstr2.sas
|
||||||
@li mp_dropmembers.sas
|
@li mp_dropmembers.sas
|
||||||
|
|
||||||
<h4> Related Macros </h4>
|
<h4> Related Macros </h4>
|
||||||
@li mp_dirlist.test.sas
|
@li mp_dirlist.test.sas
|
||||||
|
|
||||||
@version 9.2
|
@version 9.2
|
||||||
@author Allan Bowe
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
%macro mp_dirlist(path=%sysfunc(pathname(work))
|
%macro mp_dirlist(path=%sysfunc(pathname(work))
|
||||||
@@ -4050,9 +4051,24 @@ data &out_ds;
|
|||||||
set &out_ds(where=(filepath ne ''));
|
set &out_ds(where=(filepath ne ''));
|
||||||
run;
|
run;
|
||||||
|
|
||||||
/* update main table */
|
/**
|
||||||
proc append base=&outds data=&out_ds;
|
* The above transpose can mean that some updates create additional columns.
|
||||||
run;
|
* This necessitates the occasional use of datastep over proc append.
|
||||||
|
*/
|
||||||
|
%local basevars appvars usedatastep;
|
||||||
|
%let basevars=%mf_getvarlist(&outds);
|
||||||
|
%let appvars=%mf_getvarlist(&out_ds);
|
||||||
|
%let newvars=%length(%mf_wordsinstr1butnotstr2(Str1=&appvars,Str2=&basevars));
|
||||||
|
|
||||||
|
%if %mf_existds(&outds) and &newvars>0 %then %do;
|
||||||
|
data &outds;
|
||||||
|
set &outds &out_ds;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
proc append base=&outds data=&out_ds force nowarn;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
/* recursive call */
|
/* recursive call */
|
||||||
%if &maxdepth>&level or &maxdepth=MAX %then %do;
|
%if &maxdepth>&level or &maxdepth=MAX %then %do;
|
||||||
@@ -13063,8 +13079,10 @@ data _null_;
|
|||||||
put ' ';
|
put ' ';
|
||||||
put '%mend mf_getuser; ';
|
put '%mend mf_getuser; ';
|
||||||
/* WEBOUT END */
|
/* WEBOUT END */
|
||||||
put '%macro webout(action,ds,dslabel=,fmt=,missing=NULL);';
|
put '%macro webout(action,ds,dslabel=,fmt=,missing=NULL,showmeta=NO);';
|
||||||
put ' %mm_webout(&action,ds=&ds,dslabel=&dslabel,fmt=&fmt,missing=&missing)';
|
put ' %mm_webout(&action,ds=&ds,dslabel=&dslabel,fmt=&fmt,missing=&missing';
|
||||||
|
put ' ,showmeta=&showmeta';
|
||||||
|
put ' )';
|
||||||
put '%mend;';
|
put '%mend;';
|
||||||
run;
|
run;
|
||||||
|
|
||||||
@@ -18257,8 +18275,10 @@ data _null_;
|
|||||||
put '%global __program _program;';
|
put '%global __program _program;';
|
||||||
put '%let _program=%sysfunc(coalescec(&__program,&_program));';
|
put '%let _program=%sysfunc(coalescec(&__program,&_program));';
|
||||||
put ' ';
|
put ' ';
|
||||||
put '%macro webout(action,ds,dslabel=,fmt=,missing=NULL);';
|
put '%macro webout(action,ds,dslabel=,fmt=,missing=NULL,showmeta=NO);';
|
||||||
put ' %mv_webout(&action,ds=&ds,dslabel=&dslabel,fmt=&fmt,missing=&missing)';
|
put ' %mv_webout(&action,ds=&ds,dslabel=&dslabel,fmt=&fmt,missing=&missing';
|
||||||
|
put ' ,showmeta=&showmeta';
|
||||||
|
put ' )';
|
||||||
put '%mend;';
|
put '%mend;';
|
||||||
run;
|
run;
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,7 @@
|
|||||||
Credit for the rename approach:
|
Credit for the rename approach:
|
||||||
https://communities.sas.com/t5/SAS-Programming/SAS-Function-to-convert-string-to-Legal-SAS-Name/m-p/27375/highlight/true#M5003
|
https://communities.sas.com/t5/SAS-Programming/SAS-Function-to-convert-string-to-Legal-SAS-Name/m-p/27375/highlight/true#M5003
|
||||||
|
|
||||||
|
Usage:
|
||||||
usage:
|
|
||||||
|
|
||||||
%mp_dirlist(path=/some/location, outds=myTable, maxdepth=MAX)
|
%mp_dirlist(path=/some/location, outds=myTable, maxdepth=MAX)
|
||||||
|
|
||||||
@@ -23,12 +22,12 @@
|
|||||||
X CMD) do please raise an issue!
|
X CMD) do please raise an issue!
|
||||||
|
|
||||||
|
|
||||||
@param [in] path= for which to return contents
|
@param [in] path= (%sysfunc(pathname(work))) Path for which to return contents
|
||||||
@param [in] fref= Provide a DISK engine fileref as an alternative to PATH
|
@param [in] fref= (0) Provide a DISK engine fileref as an alternative to PATH
|
||||||
@param [in] maxdepth= (0) Set to a positive integer to indicate the level of
|
@param [in] maxdepth= (0) Set to a positive integer to indicate the level of
|
||||||
subdirectory scan recursion - eg 3, to go `./3/levels/deep`. For unlimited
|
subdirectory scan recursion - eg 3, to go `./3/levels/deep`. For unlimited
|
||||||
recursion, set to MAX.
|
recursion, set to MAX.
|
||||||
@param [out] outds= the output dataset to create
|
@param [out] outds= (work.mp_dirlist) The output dataset to create
|
||||||
@param [out] getattrs= (NO) If getattrs=YES then the doptname / foptname
|
@param [out] getattrs= (NO) If getattrs=YES then the doptname / foptname
|
||||||
functions are used to scan all properties - any characters that are not
|
functions are used to scan all properties - any characters that are not
|
||||||
valid in a SAS name (v7) are simply stripped, and the table is transposed
|
valid in a SAS name (v7) are simply stripped, and the table is transposed
|
||||||
@@ -49,13 +48,15 @@
|
|||||||
- OS SPECIFIC variables, if <code>getattrs=</code> is used.
|
- OS SPECIFIC variables, if <code>getattrs=</code> is used.
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_existds.sas
|
||||||
|
@li mf_getvarlist.sas
|
||||||
|
@li mf_wordsinstr1butnotstr2.sas
|
||||||
@li mp_dropmembers.sas
|
@li mp_dropmembers.sas
|
||||||
|
|
||||||
<h4> Related Macros </h4>
|
<h4> Related Macros </h4>
|
||||||
@li mp_dirlist.test.sas
|
@li mp_dirlist.test.sas
|
||||||
|
|
||||||
@version 9.2
|
@version 9.2
|
||||||
@author Allan Bowe
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
%macro mp_dirlist(path=%sysfunc(pathname(work))
|
%macro mp_dirlist(path=%sysfunc(pathname(work))
|
||||||
@@ -193,9 +194,24 @@ data &out_ds;
|
|||||||
set &out_ds(where=(filepath ne ''));
|
set &out_ds(where=(filepath ne ''));
|
||||||
run;
|
run;
|
||||||
|
|
||||||
/* update main table */
|
/**
|
||||||
proc append base=&outds data=&out_ds;
|
* The above transpose can mean that some updates create additional columns.
|
||||||
run;
|
* This necessitates the occasional use of datastep over proc append.
|
||||||
|
*/
|
||||||
|
%local basevars appvars usedatastep;
|
||||||
|
%let basevars=%mf_getvarlist(&outds);
|
||||||
|
%let appvars=%mf_getvarlist(&out_ds);
|
||||||
|
%let newvars=%length(%mf_wordsinstr1butnotstr2(Str1=&appvars,Str2=&basevars));
|
||||||
|
|
||||||
|
%if %mf_existds(&outds) and &newvars>0 %then %do;
|
||||||
|
data &outds;
|
||||||
|
set &outds &out_ds;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
proc append base=&outds data=&out_ds force nowarn;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
/* recursive call */
|
/* recursive call */
|
||||||
%if &maxdepth>&level or &maxdepth=MAX %then %do;
|
%if &maxdepth>&level or &maxdepth=MAX %then %do;
|
||||||
|
|||||||
@@ -457,8 +457,10 @@ data _null_;
|
|||||||
put ' ';
|
put ' ';
|
||||||
put '%mend mf_getuser; ';
|
put '%mend mf_getuser; ';
|
||||||
/* WEBOUT END */
|
/* WEBOUT END */
|
||||||
put '%macro webout(action,ds,dslabel=,fmt=,missing=NULL);';
|
put '%macro webout(action,ds,dslabel=,fmt=,missing=NULL,showmeta=NO);';
|
||||||
put ' %mm_webout(&action,ds=&ds,dslabel=&dslabel,fmt=&fmt,missing=&missing)';
|
put ' %mm_webout(&action,ds=&ds,dslabel=&dslabel,fmt=&fmt,missing=&missing';
|
||||||
|
put ' ,showmeta=&showmeta';
|
||||||
|
put ' )';
|
||||||
put '%mend;';
|
put '%mend;';
|
||||||
run;
|
run;
|
||||||
|
|
||||||
|
|||||||
@@ -664,8 +664,10 @@ data _null_;
|
|||||||
put '%global __program _program;';
|
put '%global __program _program;';
|
||||||
put '%let _program=%sysfunc(coalescec(&__program,&_program));';
|
put '%let _program=%sysfunc(coalescec(&__program,&_program));';
|
||||||
put ' ';
|
put ' ';
|
||||||
put '%macro webout(action,ds,dslabel=,fmt=,missing=NULL);';
|
put '%macro webout(action,ds,dslabel=,fmt=,missing=NULL,showmeta=NO);';
|
||||||
put ' %mv_webout(&action,ds=&ds,dslabel=&dslabel,fmt=&fmt,missing=&missing)';
|
put ' %mv_webout(&action,ds=&ds,dslabel=&dslabel,fmt=&fmt,missing=&missing';
|
||||||
|
put ' ,showmeta=&showmeta';
|
||||||
|
put ' )';
|
||||||
put '%mend;';
|
put '%mend;';
|
||||||
run;
|
run;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user