BookmarkSubscribeRSS Feed
statadm
Fluorite | Level 6
Yes, essentially, I have to rearrange the time variables (no matter the location) until they match based on the criteria I indicated. But, I do have to keep the 13 additional variables associated with the time variables when I reorder the times. In the end, I have to actually compare the 13 variables to one another (13 variables for Time1-Time37 and compare the Timef1-Timef37), not the times. The times are just being used to match up the correct events. This is for a reliability study. I'm trying to get some help from a fellow programmer because this is taking me too long 🙂


Message was edited by: statadm
Flip
Fluorite | Level 6
I did it this way;
Transpose your data and split it such that you have a data set time with:
ID Time Var1 - Var13
data set timef with
ID TimeF
Do a cartesian join;

create table diff as
select time.*, timef.timef , abs(time-timef) as diff, min(abs(time-timef) as mindif
from time, timef where time.id = timef.id
group by time.id, time;

now select diff.* from diff where diff = mindif;

You now have the time difference on the rows with all of your variables with times matched to the closest timef. If diff is more than 5 or 15 you can drop that row.
statadm
Fluorite | Level 6
Thank you all for your recommendations. I actually do have a code that works now. I appreciate everyone's input so much.

The code is pretty long, so I'm not going to post it unless anyone is interested in seeing it.

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
  • 17 replies
  • 4020 views
  • 0 likes
  • 5 in conversation