<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Error: BY variables are not properly sorted on data set in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Error-BY-variables-are-not-properly-sorted-on-data-set/m-p/542787#M150002</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You sort your dataset by Parkname &lt;STRONG&gt;then&lt;/STRONG&gt; ParkType. You thus have to use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;by ParkName ParkType;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Mar 2019 13:47:40 GMT</pubDate>
    <dc:creator>gamotte</dc:creator>
    <dc:date>2019-03-13T13:47:40Z</dc:date>
    <item>
      <title>Error: BY variables are not properly sorted on data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-BY-variables-are-not-properly-sorted-on-data-set/m-p/542786#M150001</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2019 13:43:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-BY-variables-are-not-properly-sorted-on-data-set/m-p/542786#M150001</guid>
      <dc:creator>guest1994</dc:creator>
      <dc:date>2019-03-13T13:43:52Z</dc:date>
    </item>
    <item>
      <title>Re: Error: BY variables are not properly sorted on data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-BY-variables-are-not-properly-sorted-on-data-set/m-p/542787#M150002</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You sort your dataset by Parkname &lt;STRONG&gt;then&lt;/STRONG&gt; ParkType. You thus have to use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;by ParkName ParkType;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2019 13:47:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-BY-variables-are-not-properly-sorted-on-data-set/m-p/542787#M150002</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2019-03-13T13:47:40Z</dc:date>
    </item>
  </channel>
</rss>

