<?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: Proc sort issue in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Proc-sort-issue/m-p/820848#M34860</link>
    <description>Thanks Andrea. Tom's advice is really helpful.&lt;BR /&gt;</description>
    <pubDate>Wed, 29 Jun 2022 03:03:39 GMT</pubDate>
    <dc:creator>Dpeter</dc:creator>
    <dc:date>2022-06-29T03:03:39Z</dc:date>
    <item>
      <title>Proc sort issue</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-sort-issue/m-p/820464#M34821</link>
      <description>&lt;P&gt;Please I need assistance with Proc sort.&lt;/P&gt;&lt;P&gt;I sorted a data set by two different variables; SALES and PRODUCT. I want the product variable to be sorted in descending order while the sales variable is sorted in ascending order.&lt;/P&gt;&lt;P&gt;Here is my program:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc sort data = sashelp.shoes out = work.sortedshoes;&lt;BR /&gt;by sales descending product;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;The SALES variable gets sorted in ascending order but the PRODUCT variable was never sorted in descending order.&lt;/P&gt;&lt;P&gt;I also re-instructed as below:&lt;/P&gt;&lt;P&gt;Proc sort data = sashelp.shoes out = work.sortedshoes;&lt;BR /&gt;by descending product;&lt;/P&gt;&lt;P&gt;Proc sort data = work.shoes out = work.sortedshoes2;&lt;BR /&gt;by sales;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;....but the PRODUCT variable never still gets sorted in descending order. Please does anyone know what could be the issue?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2022 06:27:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-sort-issue/m-p/820464#M34821</guid>
      <dc:creator>Dpeter</dc:creator>
      <dc:date>2022-06-27T06:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sort issue</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-sort-issue/m-p/820470#M34822</link>
      <description>&lt;P&gt;Hardly possible to help without seeing the data used. Also please post the log, as text, so that we see what happened actually.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2022 07:07:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-sort-issue/m-p/820470#M34822</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-06-27T07:07:03Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sort issue</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-sort-issue/m-p/820476#M34823</link>
      <description>&lt;P&gt;The descending sort of product would only be visible within groups that share the same sales value. Since this is almost never the case:&lt;/P&gt;
&lt;PRE&gt; 69         proc sort data=sashelp.shoes out=check nodupkey;
 70         by sales;
 71         run;
 
 NOTE: There were 395 observations read from the data set SASHELP.SHOES.
 NOTE: 3 observations with duplicate key values were deleted.
 NOTE: The data set WORK.CHECK has 392 observations and 7 variables.
&lt;/PRE&gt;
&lt;P&gt;the product values &lt;U&gt;seem&lt;/U&gt; to not be sorted.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2022 08:05:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-sort-issue/m-p/820476#M34823</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-06-27T08:05:46Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sort issue</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-sort-issue/m-p/820577#M34830</link>
      <description>&lt;P&gt;are you sure it's incorrect? show us a proc print of work.sortedshoes&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2022 19:28:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-sort-issue/m-p/820577#M34830</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2022-06-27T19:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sort issue</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-sort-issue/m-p/820604#M34832</link>
      <description>&lt;P&gt;Show example data.&amp;nbsp; You cannot sort a single dataset in two different ways.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your first PROC SORT does what you asked for.&amp;nbsp; Just look at the resulting dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data = sashelp.shoes out = work.sortedshoes;
  by sales descending product;
run;

proc print data=sortedshoes (obs=10);
  var sales product;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As you can see the values of SALES are increasing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Obs           Sales    Product

  1            $325    Sandal
  2            $449    Sport Shoe
  3            $450    Sport Shoe
  4            $554    Sandal
  5            $601    Sandal
  6            $712    Sandal
  7            $736    Sandal
  8            $737    Sandal
  9            $801    Sport Shoe
 10            $936    Sport Shoe
&lt;/PRE&gt;
&lt;P&gt;To tell if the values of PRODUCT are decreasing within a given value of SALES just look at the observations that have the same value of SALES.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dups;
  set sortedshoes;
  by sales;
  if not (first.sales and last.sales);
run;

proc print;
  var sales product;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;Obs           Sales    Product

 1           $1,190    Sandal
 2           $1,190    Sandal
 3           $1,520    Sandal
 4           $1,520    Boot
 5           $8,365    Sport Shoe
 6           $8,365    Boot

&lt;/PRE&gt;
&lt;P&gt;So you can see for the observations were SALES are 1,520 or 8,365 the two different values or PRODUCT are sorted in DESCENDING order just like you asked for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2022 21:15:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-sort-issue/m-p/820604#M34832</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-06-27T21:15:10Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sort issue</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-sort-issue/m-p/820845#M34857</link>
      <description>Thanks for your help. Tom's advise is really helpful.</description>
      <pubDate>Wed, 29 Jun 2022 02:56:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-sort-issue/m-p/820845#M34857</guid>
      <dc:creator>Dpeter</dc:creator>
      <dc:date>2022-06-29T02:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sort issue</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-sort-issue/m-p/820846#M34858</link>
      <description>Thanks for your assistance. that was helpful.</description>
      <pubDate>Wed, 29 Jun 2022 02:58:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-sort-issue/m-p/820846#M34858</guid>
      <dc:creator>Dpeter</dc:creator>
      <dc:date>2022-06-29T02:58:11Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sort issue</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-sort-issue/m-p/820847#M34859</link>
      <description>Hi Tom,&lt;BR /&gt;Thanks for your advise. I see that the Product variable is descending within the corresponding increasing sales variable. Thanks&lt;BR /&gt;This is really helpful. Thanks</description>
      <pubDate>Wed, 29 Jun 2022 03:00:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-sort-issue/m-p/820847#M34859</guid>
      <dc:creator>Dpeter</dc:creator>
      <dc:date>2022-06-29T03:00:50Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sort issue</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-sort-issue/m-p/820848#M34860</link>
      <description>Thanks Andrea. Tom's advice is really helpful.&lt;BR /&gt;</description>
      <pubDate>Wed, 29 Jun 2022 03:03:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-sort-issue/m-p/820848#M34860</guid>
      <dc:creator>Dpeter</dc:creator>
      <dc:date>2022-06-29T03:03:39Z</dc:date>
    </item>
  </channel>
</rss>

