Hi!
Here's a SAS macro program that does the lookup for you. It uses a special dataset, SASHELP.VCOLUMN -- one of the "dictionary" datasets that list things like table names, library names, columns, etc. There may be an SCL function, but if so, I'm not conversant enough with SCL to find it.
When you invoke the macro program the first time
[pre]
%lookvar(lib=sashelp, mem=prdsale, var=region);
[/pre]
the macro program CREATES a macro variable called GOTVAR that will be set to 'yes' if the desired variable was found. Then it makes the library and memname and var name global variables so they can be accessed by the %USEINFO macro program.
It doesn't exactly invoke like a function, but close.
cynthia
[pre]
options nomprint nosymbolgen nomlogic;
%macro lookvar(lib=sashelp, mem=class, var=age);
%global gotvar slib smem svar;
%let gotvar=no;
%let lib = %upcase(&lib);
%let mem = %upcase(&mem);
%let var = %upcase(&var);
%let svar = %upcase(&var);
%let slib = %upcase(&lib);
%let smem = %upcase(&mem);
data findvar(keep=libname memname name type length format label);
set sashelp.vcolumn;
where libname="&lib" and memname="&mem";
if upcase(name) = "&var" then do;
call symput('gotvar','yes');
end;
run;
%mend lookvar;
%macro useinfo;
%global gotvar;
%if &gotvar = yes %then %do;
proc print data=&slib..&smem (obs=10);
title "The variable &svar found in &slib..&smem";
run;
%end;
%if &gotvar = no %then %do;
%put =====> =====> <===== <=====;
%put Variable &svar NOT found in &slib..&smem;
%put =====> =====> <===== <=====;
%end;
%mend useinfo;
%lookvar(lib=sashelp, mem=prdsale, var=region);
run;
%useinfo;
run;
** after LOOKVAR executes, you can test the value;
** of GOTVAR since it is a global variable;
%lookvar(lib=sashelp, mem=prdsale, var=age);
run;
%useinfo;
run;
[/pre]