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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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