suppose i have two tables, table A and table B both having same column and data types.Either table A or B can have updated values.
I have to fetch data from updated table only.What should be the query.
What constitutes an 'updated value'? Please be more specific in your requirements and preferably illustrate your problem with sample data.
let updated value would be date.
The following query examines properties of two data sets in the same library and reports the name of the data set with the latest modification datetime of for the tables:
proc sql; select memname from dictionary.tables where libname='SASHELP' and memname in ('CLASS' 'BASEBALL') HAVING modate=max(modate) ; quit;
It does not examine any values or the properties of any variables in either of the tables but is the closest I can think of to identify which table might be 'updated'.
/*create sample data 1*/
data samp_a;
set sashelp.class;
run;
/*Wait for 1 minute before processing the second sample data to simulate the scenario*/
Data _null_;
wait=sleep(60,1);
Run;
/*create sample data 1*/
data samp_b;
set sashelp.class;
run;
%let op=%sysfunc(open(samp_a));
*use the MODTE to obtain the modified date1 and time in sas datetime format;
%let mt1=%sysfunc(attrn(&op,MODTE));
%let op=%sysfunc(close(&op));
%let op=%sysfunc(open(samp_b));
*use the MODTE to obtain the modified date2 and time in sas datetime format;
%let mt2=%sysfunc(attrn(&op,MODTE));
%let op=%sysfunc(close(&op));
*Print the sas datetime values to log;
%put &=mt1 &=mt2;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.