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;

 

 

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