BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Philmingo
Fluorite | Level 6

I am looking to print the number of observations from a list of SAS tables.  I do NOT want them printed to the SAS log; I would like it as output from my code as either a SAS table or a report/summary.  I am avoiding using a proc sql count(# of obs) as I have several tables that are millions of rows long and that will be less efficient.  I would like the output to be the table name and then the number of observations in that table. An example is below.  

 

Table NameNumber of Observations
WORK.CLAIMS120,000,000
WORK.CLAIMS220,000,000
WORK.CLAIMS325,000,000
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Query the SAS table, sashelp.vtable which contains all tables and the number of records. This assumes your are not using a linked database table.

 

proc sql;
create table record_counts as
select  libname, memname, nobs
from sashelp.vtable
where libname='WORK' and upper(memname) like 'CLAIMS%';
quit;

If you also check out the knowledge base on here, people have posted some good references for creating metadata and codebooks. 

View solution in original post

1 REPLY 1
Reeza
Super User

Query the SAS table, sashelp.vtable which contains all tables and the number of records. This assumes your are not using a linked database table.

 

proc sql;
create table record_counts as
select  libname, memname, nobs
from sashelp.vtable
where libname='WORK' and upper(memname) like 'CLAIMS%';
quit;

If you also check out the knowledge base on here, people have posted some good references for creating metadata and codebooks. 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1 reply
  • 1260 views
  • 4 likes
  • 2 in conversation