05-03-2016 05:49 AM
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.
Create Table Views as
Where ViewName = 'MyView'
and DefCol like '%datasetname%'
Thank you in advance.
05-03-2016 06:13 AM
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.
05-03-2016 08:04 AM
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;