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

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
  • 777 views
  • 3 likes
  • 2 in conversation