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;
Hello,
You sort your dataset by Parkname then ParkType. You thus have to use
by ParkName ParkType;
Hello,
You sort your dataset by Parkname then ParkType. You thus have to use
by ParkName ParkType;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.