BookmarkSubscribeRSS Feed
mionnh
Calcite | Level 5
proc import datafile='C:\Users\n01427744\My Files\OneDrive\Files\SAS\ksi.csv'

    out = work.ksi

    dbms = csv;

run;


proc contents data=ksi;

run;


proc sort data=ksi

          out = work.KSI_sortbyYearAccnum;

    by Year Accnum;

run;


data AGGKSI;

    set work.ksi_sortbyyearaccnum(Keep= Accnum Year Time Street1 Street2 offset road_class District wardnum Division 

                                  LATITUDE LONGITUDE LOCCOORD ACCLOC TRAFFCTL VISIBILITY LIGHT RDSFCOND ACCLASS IMPACTYPE

                                  PEDESTRIAN CYCLIST AUTOMOBILE MOTORCYCLE TRUCK TRSN_CITY_VEH EMERG_VEH

                                  PASSENGER SPEEDING AG_DRIV REDLIGHT ALCOHOL DISABILITY Neighbourhood);

by year accnum;

if last.accnum;

run;


proc print data=aggksi;

run;
2 REPLIES 2
japelin
Rhodochrosite | Level 12
  • The SAS code can be pasted using the "Insert SAS Code" icon on the editing screen for easier viewing.
  • What is the "NAME" you are referring to?
  • I can't determine it from the code alone; please paste the data in a usable format, such as a data step using datalines or as an attachment.
  • Please add a more specific description what you want to do.
ballardw
Super User

Very often any question related to COUNT means that Proc FREQ is likely a good start. You can count individual levels of each variable or combinations of variables by using a * between names on a Tables statement. You may want the /list option for readability for multiple variables.

 

The Proc Freq statement option Order=freq means the output tables will be in decreasing order of frequency (i.e. decreasing count)

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2 replies
  • 717 views
  • 1 like
  • 3 in conversation