Here are some tips for How to share your SAS knowledge with your professional network.
- Posting number 182, dated 3 Feb 1996 17:47:13
- Date: Sat, 3 Feb 1996 17:47:13 EDT
- Summary: SQL and the SAS system's DICTIONARY files are handy
- subject: Re: Variables in Multiple Datasets
%macro findvars ( lib = , vlist = ) ; options nolabel mprint; %let vlist = %upcase ( &vlist ); data __vars ( keep = name ) ; length name $ 32 ; do i = 1 to 200 until( scan( "&vlist" , i ) = ' ' ); name = scan ( "&vlist" , i ) ; if name ^= ' ' then output __vars ; end ; run; proc sql; select f.name , v.memname , count( distinct v.memname ) as found from __vars as f left join (select memname ,name from dictionary.columns where libname = upcase("&lib") and memtype = 'DATA' and " &vlist " contains ' '||trim(name)||' ' ) as v on f.name = v.name group by f.name order by f.name, v.memname; quit; options label; %mend findvars;
harvesting and code polishing by:
--macro maven == the radical programmer 13:21, 23 May 2012 (EDT)