BookmarkSubscribeRSS Feed
jayanth_sas
Calcite | Level 5


Hi,

I have some 50 tables and i need  table count of each. Apart from running select count (*) from table name.

Do we have any other method that will give in single shot 50 or 100 tables count and table name with proper layout.

Can anyone suggest on this plz.

Header 1Header 2
table name1count1
table name2count2
table name3count3

|

|

|

6 REPLIES 6
Cynthia_sas
SAS Super FREQ

Hi:

  This is something you could do quite easily by reading the DICTIONARY.TABLES dataset. There are a lot of previous posts about finding out information about your table and columns using this technique. In addition, there are Tech Support notes like this:

http://support.sas.com/kb/25/436.html, and documentation topics like this one:

http://support.sas.com/documentation/cdl/en/sqlproc/65065/HTML/default/viewer.htm#n0cqcq4fhom7qtn17t... (see example 6)

 

  The variables in DICTIONARY.TABLES include a variable called NOBS and another called CRDATE -- which are the count of physical observations and the creation date, respectively.

 

cynthia

jayanth_sas
Calcite | Level 5

Hi Cynthia,

Thank you for your information. But i am little worried to use dictionary. Because there seems to be every time i need to select respective table name in find for your contents. Actually i dont want contents at all. I only require table name and respective count of that table like 500 observations. if number of tables are 50 or >50 at single shot how i can get the output which shows 50 table names with respective counts in proper lay out.

Reeza
Super User

Open up sashelp.vtable and take a look at the columns and run the following and see what it outputs.

Proc print data=sashelp.vtable (obs=20);

var libname memname nobs nlobs nvar;

run;

jayanth_sas
Calcite | Level 5

Hi reeza,

Its nice. But i have created a new library and i only want count from that particular library and not from any other (rawdata,gismaps ets) with out mentioning obs. Can you plz suggest me

Tom
Super User Tom
Super User

I am not sure what your issue is.  Just run the query and use the data in whatever way you want.

Use a WHERE clause the select the tables you are interested in.

libname mylib 'mypath';

proc sql ;

select memname,nlobs

from dictionary.tables

where libname='MYLIB'

;

quit;

jayanth_sas
Calcite | Level 5

Thank you Tom.

Got it

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
  • 6 replies
  • 1064 views
  • 0 likes
  • 4 in conversation