08-04-2016 02:07 PM
Is there any easy way to find where the list of variables present in the libarary.
I have list of variables ABC , BDC , XYZ...So on.
I would like to know which table contains these fields in library,
08-04-2016 02:37 PM
There are several ways to do this. One way is to use SASHELP dictionary views.
For example, the following code finds all data sets in the SASHELP library that contain a numeric variable named "date" or "name":
data FindVars; set sashelp.vcolumn; if libname="SASHELP" and Type="num" and upcase(name) in ("NAME" "DATE"); run; proc print; run;
08-04-2016 02:41 PM - edited 08-04-2016 02:43 PM
Just to add a little context, since Reeza has already pointed you in the right direction:
libname mylib '/path/to/some/folder';
select memname, name from dictionary.columns where libname='MYLIB' and upcase(name) in ('ABC', 'XYZ');
Within dictionary.columns, the LIBNAME values are stored in uppercase, but the variable NAME values can be mixed case.
Other fields related to each variable are also contained in dictionary.columns and can be extracted similarly.
***** EDITED: Nothing wrong with Rick's suggestion either ... we were evidently typing at the same time.
08-05-2016 02:49 AM
Just an addendum for clarification:
dictionary.columns is available within proc sql.
sashelp.vcolumn is available outside of proc sql (for data and proc steps) and is in fact a view to dictionary.columns
Both are built/executed dynamically when they are used.
08-19-2016 03:13 PM - edited 08-19-2016 03:14 PM
I am trying to find PrinBal variable belongs to which table in MTGAE libaray but It is taking long time to run.
Can you help why?
WHERE UPCASE(LIBNAME) in ("MTGAE") AND memtype ="DATA" And
NAME in ("PrinBal") ;