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. 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1 reply
  • 813 views
  • 4 likes
  • 2 in conversation