Hello, I am using the following code into a macro function to get the libname, memname, data type and the modate.
proc sql;
create table &nsource. as
select libname,
memname,
memtype,
modate
from sashelp.vtable
where libname="&lbname."
and &enddate.>= datepart(modate)>= &startdate.;
quit;
So I am getting a table gathering this information for each &nsource. Each table could contains about 30 observations.
When those table are created, I could use the libname and the memname as well as a proc sql as below to get the min and max value.
proc sql;
create table &nsource_memname as
select min(transaction_dt) as mintransacdate,
max(transaction_dt) as maxtransacdate,
from &nsource;
quit;
I wonder if there is a more efficient way to do that?
I might be tempted to try something along the lines of:
proc sql; select catx('.',libname,Memname) into :memlist separated by ' ' from sashelp.vtable where libname="&lbname." and memtype='DATA' and &enddate.>= datepart(modate)>= &startdate.; quit; data need; set &memlist. indsname=dsn; source=dsn; run; proc summary data=need nway; class source; var transaction_dt; output out=want (drop=_:) min(transaction_dt)=mintransacdate max(transaction_dt)=maxtransacdate ; run;
This creates one output data set with the source data set name as a variable.
Can we see the entire code?
How could this work anyway? There is no variable named transaction_dt in data set &nsource.
I might be tempted to try something along the lines of:
proc sql; select catx('.',libname,Memname) into :memlist separated by ' ' from sashelp.vtable where libname="&lbname." and memtype='DATA' and &enddate.>= datepart(modate)>= &startdate.; quit; data need; set &memlist. indsname=dsn; source=dsn; run; proc summary data=need nway; class source; var transaction_dt; output out=want (drop=_:) min(transaction_dt)=mintransacdate max(transaction_dt)=maxtransacdate ; run;
This creates one output data set with the source data set name as a variable.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.