sas code which fetch all the dataset that are modified and created in may’25 and their count from grp/credit lib. Actually i want exact count of dataset that are created or modified in may month from grp/credit lib.
Assuming you have the GRP and CREDIT librefs already defined you can use PROC CONTENTS to get information about datasets and variables at the same time.
proc contents data=grp._all_ noprint out=grp_contents; run;
proc contents data=credit._all_ noprint out=credit_contents; run;
You can also query the DICTIONARY. (pseudo) tables from SQL code.
If you just want the tables names then filter. So perhaps something like this?
proc sql;
create table tables as
select libname,memname,modate
from dictionary.tables
where libname in ("GRP" "CREDIT")
having intnx('dtmonth',modate,0)='01MAY2025:00:00'dt
;
quit;
Hello Sanjeevas,
I think that Tom's idea is a better one in that it gives you a handy look-up list of dataset names from which you can then get your COUNT(*) from. In my experience, once you know the number of datasets someone then asks you for more information about some of those datasets.
However, here are two other options for you to consider.
************************************************************************;
*Option 1 - Just create a report showing the number of datasets modified;
************************************************************************;
Proc SQL;
Title "Number of Datasets that were Created/Modified in May 2025";
Select Count(*) As Number_Of_Tables
From DICTIONARY.TABLES
Where Libname In ("GRP" "CREDIT", "DEPLOYED")
And
IntNx("dtmonth",MoDate,0)="01MAY2025:00:00"dt
;
Quit;
****************************************************************************;
*Option 2 - Create a macro variable to hold the number of datasets modified.;
****************************************************************************;
Proc SQL NoPrint;
Select Count(*) As Number_Of_Tables INTO :Modified_Count
From DICTIONARY.TABLES
Where Libname In ("GRP" "CREDIT", "DEPLOYED")
And
IntNx("dtmonth",MoDate,0)="01MAY2025:00:00"dt
;
Quit;
********************************************************************************;
*Prove that our macro contains the number we expect by writing it to the SASLOG.;
********************************************************************************;
%Put Macro Variable Modified_Count resolves to: &Modified_Count;
If you just want to know the number of modified datasets, either of the above options should work for you.
However, if you want the remainder of your code to take some action based on how many datasets were modified in May 2025, option 2 is better because you can use the macro variable &Modified_Count
to drive things like a Do/End loop or to take decisions about whether to execute certain bits of code.
I would imagine that eventually you would need to know about the number of datasets modified in June, then July etc. If this is the case, macro variables and a tiny bit of macro code would really help you a lot.
For the moment, I hope that this helps.
Downunder Dave
Wellington
@Sanjeevas wrote:
Sorry this didn’t work as i want the count(*) of all datasets which are created or modified in may month ftom ”grp/credit/deployed” lib
Why doesn't it work for you? It works fine for me.
proc sql;
create table tables as
select libname,memname,modate,nlobs
from dictionary.tables
where libname in ("GRP" "CREDIT" "DEPLOYED")
having intnx('dtmonth',modate,0)='01MAY2025:00:00'dt
;
quit;
Are they not actually SAS datasets? If they are views then you will have to actually count the observations manually. And I have not idea how to determine if the number of observations that a view returns has changed.
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
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.
Ready to level-up your skills? Choose your own adventure.