Ksharp, It works Thank you so much Below I have a small set of questions that are related on how to improve the code you provided and how to do a similar merge. Hope you will be able to support me on this. I would like to make a similar merge of the datasets as the one described before. This time instead of exact time matching, I would like to “locate” the value in dataset “Chfreuters3” which is 60 seconds or e.g 1800 seconds after datetime in Chfdaily2. Any suggestions on how I should change the code you provided? Also I would like to do the opposite, locate the value which is 60 seconds before datetime in Chfdaily2. The difference from the exercise from before is that in the output table I would like to add only a specified number of variables, e.g datetime and midquote and not all from chfreuters3. Going back to the code you provided: How datetime can be included in the final output table for dataset Chfreuters3, since datetime of dataset Chfdaily2 might be different of datetime of dataset Chfreuters3 in the output table. This is the case when we do not have an exact time match from the two sets and I would like to retain both new dateformats. Can you have a look at the result I uploaded under filename want? Why do you think row 5 gives such a result? For info here is the code I used – I only updated yours by using different datasets and library locations libname neo v9 'd:\phd thesis\sas files'; data neo.c2; set neo.Chfdaily2; datetime=input(catx(':',value_date,newtime),anydtdtm20.); format datetime datetime.; run; data neo.c3; set neo.Chfr; datetime=dhms(datepart(Date_G_),0,0,int(Time_G_)); format datetime datetime.; run; data neo.want; if _n_ eq 1 then do; if 0 then set c3; declare hash ha(hashexp:16,dataset:'c3'); ha.definekey('_ric2','datetime'); ha.definedata(all:'Y'); ha.definedone(); end; call missing(of _all_); set c2; _ric2 =cur1cur2; datepart=datepart(datetime); do while(ha.find() ne 0); datetime+1; if datepart ne datepart(datetime) then leave; end; drop datepart LOC Price Volume; run;
... View more