You could do the conversion "on the fly" in the PROC SQL step by replacing a.event_northing by input(event_northing, 32.)and similarly for a.event_easting. The error messages clearly indicate that event_northing and event_easting are character variables, whereas the GEODIST function requires numeric arguments. Hope someone can help, and that the question is understandable. If the "Day" in the "Main_dataset" are from 2018 or 2019 the new variables should be generated from "Observations_2018" or "Observations_2019) respectively. True line distance would be preferred, but straight line is also acceptable if true line is impossible.
In this fictive dataset, I'm not sure, that the variables actually are within these distances from each other. It should only look for events that happened at or before 15FEB2017 (the "Day" in ID = 1). If we take first observation in the "Main_dataset" with ID = 1, then I want the three new variables to count how many observations from the "Observations_2017" (because the variable "Day" in the "Main_dataset" is 2017) that took place in 0-500, 500-1000, and 1000-1500 meters away from the coordinates in ID = 1. What I want is to generate three new variables in my "Main_dataset" called "0_500", "500_1000" and "1000_1500". Lets look at one of them fx "Observations_2017": The only difference, is that the observations in each of them at limited to that year (2017, 2018, 2019). Then I have three other datasets (that are quite similar) lets call them "Observations_2017", "Observations_2018", and "Observations_2019". Imagine this fictive dataset lets call it "Main_dataset": I'm quite new to SAS and have a complicated question.