BookmarkSubscribeRSS Feed
JoeMadden
Fluorite | Level 6

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.

 

2 REPLIES 2
LinusH
Tourmaline | Level 20

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.

Data never sleeps
BrunoMueller
SAS Super FREQ

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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1222 views
  • 2 likes
  • 3 in conversation