BookmarkSubscribeRSS Feed
asuman
Obsidian | Level 7

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.

 

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

What constitutes an 'updated value'? Please be more specific in your requirements and preferably illustrate your problem with sample data.

asuman
Obsidian | Level 7

let updated value would be date.

ballardw
Super User

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'.

r_behata
Barite | Level 11
/*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;




hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1093 views
  • 2 likes
  • 4 in conversation