mirror of
https://github.com/sasjs/core.git
synced 2026-06-12 05:30:22 +00:00
feat: adding tests, adding param to mfv_existsashdat, updating README
This commit is contained in:
@@ -6,14 +6,17 @@
|
||||
%if %mfv_existsashdat(libds=casuser.sometable) %then %put yes it does!;
|
||||
|
||||
The function uses `dosubl()` to run the `table.fileinfo` action, for the
|
||||
specified library, filtering for `*.sashdat` tables. The results are stored
|
||||
in a WORK table (&outprefix._&lib). If that table already exists, it is
|
||||
queried instead, to avoid the dosubl() performance hit.
|
||||
specified library, filtering for `*.sashdat` tables.
|
||||
|
||||
IMPORTANT NOTE - The results are cached in a WORK table (&outprefix._&lib).
|
||||
If that table already exists, it is queried instead, to avoid the
|
||||
dosubl() performance hit.
|
||||
|
||||
To force a rescan, just use a new `&outprefix` value, or delete the table(s)
|
||||
before running the function.
|
||||
|
||||
@param [in] libds library.dataset
|
||||
@param [in] usecache= (1) Set to 0 to rebuild the cache
|
||||
@param [out] outprefix= (work.mfv_existsashdat)
|
||||
Used to store current HDATA tables to improve subsequent query performance.
|
||||
This reference is a prefix and is converted to `&prefix._{libref}`
|
||||
@@ -24,14 +27,14 @@
|
||||
@author Mathieu Blauw
|
||||
**/
|
||||
|
||||
%macro mfv_existsashdat(libds,outprefix=work.mfv_existsashdat
|
||||
%macro mfv_existsashdat(libds,usecache=1,outprefix=work.mfv_existsashdat
|
||||
);
|
||||
%local rc dsid name lib ds;
|
||||
%let lib=%upcase(%scan(&libds,1,'.'));
|
||||
%let ds=%upcase(%scan(&libds,-1,'.'));
|
||||
|
||||
/* if table does not exist, create it */
|
||||
%if %sysfunc(exist(&outprefix._&lib)) ne 1 %then %do;
|
||||
%if &usecache ne 1 or %sysfunc(exist(&outprefix._&lib)) ne 1 %then %do;
|
||||
%let rc=%sysfunc(dosubl(%nrstr(
|
||||
/* Read in table list (once per &lib per session) */
|
||||
proc cas;
|
||||
@@ -41,7 +44,7 @@
|
||||
quit;
|
||||
/* Only keep name, without file extension */
|
||||
data &outprefix._&lib;
|
||||
set &outprefix._&lib(where=(Name like '%.sashdat') keep=Name);
|
||||
set &outprefix._&lib(where=(upcase(Name) like '%.SASHDAT') keep=Name);
|
||||
Name=upcase(scan(Name,1,'.'));
|
||||
run;
|
||||
)));
|
||||
|
||||
Reference in New Issue
Block a user