Hi There,
I've been racking my brains all morning trying to figure this one out.
Is there a way to query the definition of a view, for example I want to know how many views in my library use a particular table/dataset.
Proc Sql;
Create Table Views as
Select *
From <ViewDefs>
Where ViewName = 'MyView'
and DefCol like '%datasetname%'
;
Quit;
Thank you in advance.
Tha's a great question!
Unfortunately, I'm not aware of any out-of-box functionality for this.
But it would good thought, like in SQL Server where you can see dependencies of a view directly.
So, perhaps you need to parse all view definitions (looking for keywords like from, join etc).
But then you might have data step views...
When dealing with larger implementations, I usually have access to metadata tool, in SAS that would be DI Studio. Then you create the metadata first, then create any view/table with code derived directly from metadata.
Hi To query which views are available you can use DICTIONARY.VIEWS.
As @LinusH pointed out, to actually figure out what tables and columns are coming from which tables/views you need to parse the output of the DESCRIBE statement from Proc SQL or the DATA Step.
Below are some code examples:
data work.ds_view / view=work.ds_view;
set sashelp.cars;
run;
proc sql;
create table myviews as
select
*
from
dictionary.views
;
quit;
proc sql;
describe view SASHELP.VTABLE;
quit;
data view=work.ds_view;
describe;
run;
Bruno
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.