-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from macropeople/development
feat: new mf_getattrc macro
- Loading branch information
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
@file | ||
@brief Returns a character attribute of a dataset. | ||
@details Can be used in open code, eg as follows: | ||
%put Dataset label = %mf_getattrc(sashelp.class,LABEL); | ||
%put Member Type = %mf_getattrc(sashelp.class,MTYPE); | ||
@param libds library.dataset | ||
@param attr full list in [documentation]( | ||
https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000147794.htm) | ||
@return output returns result of the attrc value supplied, or -1 and log | ||
message if error. | ||
@version 9.2 | ||
@author Allan Bowe | ||
**/ | ||
|
||
%macro mf_getattrc( | ||
libds | ||
,attr | ||
)/*/STORE SOURCE*/; | ||
%local dsid rc; | ||
%let dsid=%sysfunc(open(&libds,is)); | ||
%if &dsid = 0 %then %do; | ||
%put WARNING: Cannot open %trim(&libds), system message below; | ||
%put %sysfunc(sysmsg()); | ||
-1 | ||
%end; | ||
%else %do; | ||
%sysfunc(attrc(&dsid,&attr)) | ||
%let rc=%sysfunc(close(&dsid)); | ||
%end; | ||
%mend; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters