30%macro mf_getvalue(libds,variable,filter=1,fetchobs=1,warn=0
32 %local dsid rc vartype result;
34 %let vartype = %mf_getvartype(&libds,&variable);
36 %let dsid=%sysfunc(open(&libds(where=(&filter))));
37 %
if (&dsid) %then %
do;
38 %let rc = %sysfunc(fetchobs(&dsid,&fetchobs));
39 %
if (&rc ne 0) %then %
do;
41 %
if (&rc ne -1) %then %put %sysfunc(sysmsg());
43 %
if (&vartype eq N) %then %let result = .;
46 %
if (&warn) %then %
do;
47 %
if (&rc eq -1) %then %
do;
50 %quote(WARN%str(ING): Missing value returned for variable)
51 %quote(&variable after reading past end of &libds..)
58 %let syscc = %sysfunc(max(&syscc,&rc));
61 %let result = %sysfunc(
64 ,%sysfunc(varnum(&dsid,&variable))
68 %let rc = %sysfunc(close(&dsid));
74 %put %sysfunc(sysmsg());
75 %let syscc = %sysfunc(max(&syscc,%sysfunc(sysrc())));