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
Diamond | Level 26

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

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