Hi All,
Based on data could anyone assist me - making program that contains
test_date closest to delivery_date.
delivery_date test_date
11/16/2011 21/nov/2011
10/nov/2011
15/oct/2010
Thanks in advance
Hi, I figure you should have an 'id' variable in this case, but if you don't, feel free to take it out:
proc sql;
create table want as
select distinct a.* from have a, have b
where a.id=b.id
group by a.id /*I assume you should have one*/, b.delivery_date
having abs(b.test_date-a.delivery_date)=min(abs(a.delivery_date-b.test_date));
quit;
Haikuo
I have a variable delivery_date with one observation and test_date with 20 observations. I'd like to find the closest date in test_date to delivery_date by find the minimum absolute difference and retain the minimum value.
When I merge the datasets I only get two observations paired up and get missing values for the rest. Would anyone please explain how to go about this with maybe a do loop or...???
Thank you!
| delivery_date | ||||||||||||||||||||||
| 11/16/2011 | ||||||||||||||||||||||
|
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.