DATA Step, Macro, Functions and more

SAS Libraries

Reply
New Contributor
Posts: 2

SAS Libraries

[ Edited ]

hello everyone,

 

few days back i have attended an interview, the interviewer asked a question:-

consider a case, there are 50 libraries, each libraries has some sas datasets. so i want to list only those sasdatas  which has a column or variable X in all the sas datasets from all the libraries?????

plzz help me 

Trusted Advisor
Posts: 1,137

Re: SAS Libraries

[ Edited ]
Posted in reply to santhoshlekkala

Ok in this case, sashelp.vcolumns will help us. in this we could check all the libraries, datasets and the variables they have.

 

in your case check like this

 

data want;

set sashelp.vcolumns;

where name='X';

run;

 

This will subset on the list of libraries(libname) and datasets (memname) that have variable with name X.

Thanks,
Jag
Trusted Advisor
Posts: 1,137

Re: SAS Libraries

[ Edited ]
Posted in reply to santhoshlekkala

Alternatively by proc sql also we could achieve the same result

 

proc sql;
create table want as select libname, memname , name from dictionary.columns where name='X';
quit;


Thanks,
Jag
Super User
Posts: 19,772

Re: SAS Libraries

Posted in reply to santhoshlekkala

They wanted to know if you're familiar with Dictionary tables. 

 

You can find details in many papers on LEXJANSEN.COM

 

Common usages: 

Create data dictionary

Automate creation of labels or rename variables 

 

New Contributor
Posts: 2

Re: SAS Libraries

tq for help

Ask a Question
Discussion stats
  • 4 replies
  • 143 views
  • 0 likes
  • 3 in conversation