BookmarkSubscribeRSS Feed
FrithaArgus
Calcite | Level 5

Hi all,

I am a new user of SAS, and the learning curve is steep but Im getting there slowly.

I was hoping someone could help me.

What I have is two data sets.

The first data set (work.road) has information about sections of road, these sections are defined by 4 varibales; the road name (road_no) the carriage way type, whether it be left, right or single (cway) and a start and finish point (slk_start and slk_end).

The second data set (work.crashes) has information about the location and nature of crashes, where each row is a different crash. The location information about each crash includes road_no, cway and a specific point along the road (slk).

What I wish to do is create a new variable in work.road that represents the number of crashes along each section of road (or observation/row).

So my question can be worded something along the lines of: How many observations in work.crashes have the same road_no and cway and where SLK_start le SLK le SLK_end for each observation/row in work.road?

I have done alot of reading in the SAS help pages and resources and have found things including hash and hiter that seem promising, however, as I am only a new user I don't fully understand how they work and are therefore having problems trying to impose my additional limitations and criteria on the more simple examples.

Am I on the right track?

Can someone help me write some code to perform this type of merging?

Thanks a lot in advance,

Regards,

Fritha

1 REPLY 1
RichardinOz
Quartz | Level 8

Leave hash techniques aside for the time being until you are more advanced.

This question can be readily answered using Proc SQL with a left join and a count function

Richard

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 317 views
  • 3 likes
  • 2 in conversation