Macros for SAS Application Developers
No Matches File Reference

Searches all data in a library. More...

Go to the source code of this file.

Detailed Description

Scans an entire library and creates a copy of any table containing a specific string OR numeric value. Only matching records are written out. If both a string and numval are provided, the string will take precedence.


%mp_searchdata(lib=sashelp, string=Jan)
%mp_searchdata(lib=sashelp, ds=bird, numval=1)
%mp_searchdata(lib=sashelp, ds=class, string=l,outobs=5)

Outputs zero or more tables to an MPSEARCH library with specific records.

[in]lib=The libref to search (should be already assigned)
[in]ds=The dataset to search (leave blank to search entire library)
[in]string=String value to search (case sensitive, can be partial)
[in]numval=Numeric value to search (must be exact)
[out]outloc=(0) Optionally specify the directory in which to create the the output datasets with matching rows. By default it will write them to a temporary subdirectory within the WORK folder.
[out]outlib=(MPSEARCH) Assign a different libref to the output library containing the matching datasets / records
[in]outobs=set to a positive integer to restrict the number of observations
[in]filter_text=(1=1) Add a (valid) filter clause to further filter the results.

SAS Macros

Allan Bowe

Definition in file