mirror of
https://github.com/sasjs/core.git
synced 2026-04-21 07:21:31 +00:00
chore: updating all.sas
This commit is contained in:
@@ -1215,8 +1215,9 @@ or %index(&pgm,/tests/testteardown)
|
|||||||
%mend mf_getuser;
|
%mend mf_getuser;
|
||||||
/**
|
/**
|
||||||
@file
|
@file
|
||||||
@brief Retrieves a value from a dataset. If no filter supplied, then first
|
@brief Retrieves a value from a dataset. Returned value is fetched from the
|
||||||
record is used.
|
'fetchobs=' record (row 1 by default), after applying the optional filter.
|
||||||
|
|
||||||
@details Be sure to <code>%quote()</code> your where clause. Example usage:
|
@details Be sure to <code>%quote()</code> your where clause. Example usage:
|
||||||
|
|
||||||
%put %mf_getvalue(sashelp.class,name,filter=%quote(age=15));
|
%put %mf_getvalue(sashelp.class,name,filter=%quote(age=15));
|
||||||
@@ -1231,24 +1232,43 @@ or %index(&pgm,/tests/testteardown)
|
|||||||
@param [in] libds dataset to query
|
@param [in] libds dataset to query
|
||||||
@param [in] variable the variable which contains the value to return.
|
@param [in] variable the variable which contains the value to return.
|
||||||
@param [in] filter= (1) contents of where clause
|
@param [in] filter= (1) contents of where clause
|
||||||
|
@param [in] fetchobs= (1) observation to fetch. NB: Filter applies first.
|
||||||
|
|
||||||
@version 9.2
|
@version 9.2
|
||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
**/
|
**/
|
||||||
|
|
||||||
%macro mf_getvalue(libds,variable,filter=1
|
%macro mf_getvalue(libds,variable,filter=1,fetchobs=1
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
%if %mf_getattrn(&libds,NLOBS)>0 %then %do;
|
%local dsid;
|
||||||
%local dsid rc &variable;
|
|
||||||
%let dsid=%sysfunc(open(&libds(where=(&filter))));
|
%let dsid=%sysfunc(open(&libds(where=(&filter))));
|
||||||
|
%if (&dsid) %then %do;
|
||||||
|
%local rc &variable;
|
||||||
%syscall set(dsid);
|
%syscall set(dsid);
|
||||||
%let rc = %sysfunc(fetch(&dsid));
|
%let rc = %sysfunc(fetchobs(&dsid,&fetchobs));
|
||||||
|
%if (&rc ne 0) %then %do;
|
||||||
|
%put NOTE: Problem reading obs &fetchobs from &libds..;
|
||||||
|
%put %sysfunc(sysmsg());
|
||||||
|
/* Coerce an rc value of -1 (read past end of data) to a 4
|
||||||
|
that, in SAS condition code terms, represents the sysmsg
|
||||||
|
w@rning it generates. */
|
||||||
|
%if &rc eq -1 %then %let rc = 4;
|
||||||
|
/* And update SYSCC if the &rc value is higher */
|
||||||
|
%let syscc = %sysfunc(max(&syscc,&rc));
|
||||||
|
%end;
|
||||||
%let rc = %sysfunc(close(&dsid));
|
%let rc = %sysfunc(close(&dsid));
|
||||||
|
|
||||||
%trim(&&&variable)
|
%trim(&&&variable)
|
||||||
|
|
||||||
%end;
|
%end;
|
||||||
%mend mf_getvalue;/**
|
%else %do;
|
||||||
|
%put %sysfunc(sysmsg());
|
||||||
|
%let syscc = %sysfunc(max(&syscc,%sysfunc(sysrc())));
|
||||||
|
%end;
|
||||||
|
|
||||||
|
%mend mf_getvalue;
|
||||||
|
/**
|
||||||
@file
|
@file
|
||||||
@brief Returns number of variables in a dataset
|
@brief Returns number of variables in a dataset
|
||||||
@details Useful to identify those renagade datasets that have no columns!
|
@details Useful to identify those renagade datasets that have no columns!
|
||||||
|
|||||||
Reference in New Issue
Block a user