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 Name | Number of Observations |
WORK.CLAIMS1 | 20,000,000 |
WORK.CLAIMS2 | 20,000,000 |
WORK.CLAIMS3 | 25,000,000 |
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.
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.
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!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.