BookmarkSubscribeRSS Feed
hlg23
Calcite | Level 5

I think I need to complete a few to many merge. For visual purposes, I took a screenshot of the data I want to merge on two datasets, but in reality, the data is all in one Excel file, on two different tabs. Is it possible to do a proc sql procedure to merge and combine datasets on multiple variables? I need to merge the data on "siteid" AND "date" and "rater". I have 28 sites total and each site was observed 5 times (mostly by the same "rater", but sometimes a different one), with individual observations varying by day from as few as 1 to as many as 100+. I eventually want to get an average of the "sec" variables for each site observed. ("sec" is time, in seconds, spent performing observed activity). 

Screenshot (47).pngHere is some code I came up with, but I have not had a chance to run it to see if it would work : 

proc sql; 

create table <want> as

select * from <have>

group by siteid

having date=min(date)

order by siteid, date, rater;

quit;

 

 

1 REPLY 1
PeterClemmensen
Tourmaline | Level 20

Can you provide us with an example of what your desired result looks like? It is much easier to help you then.

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
  • 1 reply
  • 1035 views
  • 0 likes
  • 2 in conversation