BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
guest1994
Calcite | Level 5
ERROR: BY variables are not properly sorted on data set WORK.SORTEDTRAFFIC.
ParkName=Assateague Island NS ParkType=National Seashore Location=TRAFFIC COUNT AT FWS ENTRANCE
Count=407,276 FIRST.ParkType=1 LAST.ParkType=0 TypeCount=368,677 _ERROR_=1 _N_=5
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 6 observations read from the data set WORK.SORTEDTRAFFIC.
WARNING: The data set WORK.TYPETRAFFIC may be incomplete.  When this step was stopped there 
         were 4 observations and 2 variables.
NOTE: Compressing data set WORK.TYPETRAFFIC increased size by 100.00 percent. 
      Compressed is 2 pages; un-compressed would require 1 pages.
WARNING: Data set WORK.TYPETRAFFIC was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds

Hi,

 

I'm unable to find a solution for this code below; I'm receiving an error message in the log, 'ERROR: BY variables are not properly sorted on data set WORK.SORTEDTRAFFIC'. Why is this the case and what is wrong?

 

Many Thanks,

 

title Generating an Accumulating Column within Groups;

proc sort data=pg2.np_yearlyTraffic 

out=sortedTraffic(keep=ParkType ParkName Location Count);

*Insert BY statement;

by ParkName ParkType;

run;

 

data TypeTraffic;

set sortedTraffic;

by ParkType;

if first.ParkType=1 then TypeCount = 0;

TypeCount+Count;

format TypeCount comma12.;

keep ParkType TypeCount;

run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
gamotte
Rhodochrosite | Level 12

Hello,

 

You sort your dataset by Parkname then ParkType. You thus have to use

 

by ParkName ParkType;

 

 

View solution in original post

1 REPLY 1
gamotte
Rhodochrosite | Level 12

Hello,

 

You sort your dataset by Parkname then ParkType. You thus have to use

 

by ParkName ParkType;

 

 

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
  • 8153 views
  • 1 like
  • 2 in conversation