<?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: SAS sql whichn in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-sql-whichn/m-p/865806#M341914</link>
    <description>&lt;P&gt;No idea what you are trying to do, but to get rid of the NOTE include the variables in the SELECT list.&lt;/P&gt;
&lt;P&gt;Plus then you can debug why it does not appear to be sorting.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table epi_flu_pneumonia_deaths2 as
select
  whichc(season, '2009-2010','2010-2011','2011-2012','2012-2013','2013-2014'
         ,'2014-2015','2015-2016','2016-2017','2017-2018','2018-2019'
         ,'2019-2020','2020-2021','2021-2022') as sort1
, whichn(mmwr_week, 40,41,42,43,44,45,46,47,48,49,50,51,52,53
         ,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
         ,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39) as sort2
, week_end
, mmwr_week
, season
, flu_deaths
, pneumonia_deaths
, all_deaths 
, season_num 
from epi_flu_pneumonia_deaths
order by 1,2
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can always add a DROP= dataset option to remove the extra variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;epi_flu_pneumonia_deaths2(drop=sort1 sort2)&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 22 Mar 2023 21:51:28 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-03-22T21:51:28Z</dc:date>
    <item>
      <title>SAS sql whichn</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-sql-whichn/m-p/865804#M341913</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this code:&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table epi_flu_pneumonia_deaths2 as&lt;BR /&gt;select week_end, mmwr_week, season, flu_deaths, pneumonia_deaths, all_deaths , season_num from epi_flu_pneumonia_deaths&lt;BR /&gt;order by whichc(season, '2009-2010','2010-2011','2011-2012','2012-2013','2013-2014','2014-2015','2015-2016','2016-2017','2017-2018','2018-2019','2019-2020','2020-2021','2021-2022'),&lt;BR /&gt;whichn(mmwr_week, 40,41,42,43,44,45,46,47,48,49,50,51,52,53,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39);&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and I keep getting this note:&amp;nbsp;NOTE: The query as specified involves ordering by an item that doesn't appear in its SELECT clause.&lt;/P&gt;&lt;P&gt;and the resulting table is only sorted by the first whichc, season.&lt;/P&gt;&lt;P&gt;am I missing something?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Enrique&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2023 21:34:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-sql-whichn/m-p/865804#M341913</guid>
      <dc:creator>eramirez</dc:creator>
      <dc:date>2023-03-22T21:34:35Z</dc:date>
    </item>
    <item>
      <title>Re: SAS sql whichn</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-sql-whichn/m-p/865806#M341914</link>
      <description>&lt;P&gt;No idea what you are trying to do, but to get rid of the NOTE include the variables in the SELECT list.&lt;/P&gt;
&lt;P&gt;Plus then you can debug why it does not appear to be sorting.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table epi_flu_pneumonia_deaths2 as
select
  whichc(season, '2009-2010','2010-2011','2011-2012','2012-2013','2013-2014'
         ,'2014-2015','2015-2016','2016-2017','2017-2018','2018-2019'
         ,'2019-2020','2020-2021','2021-2022') as sort1
, whichn(mmwr_week, 40,41,42,43,44,45,46,47,48,49,50,51,52,53
         ,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
         ,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39) as sort2
, week_end
, mmwr_week
, season
, flu_deaths
, pneumonia_deaths
, all_deaths 
, season_num 
from epi_flu_pneumonia_deaths
order by 1,2
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can always add a DROP= dataset option to remove the extra variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;epi_flu_pneumonia_deaths2(drop=sort1 sort2)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Mar 2023 21:51:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-sql-whichn/m-p/865806#M341914</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-22T21:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: SAS sql whichn</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-sql-whichn/m-p/865807#M341915</link>
      <description>&lt;P&gt;The note is just that, a note and is basically a reminder to you that the appearance of your output may not appear to be ordered as expected because you did not include the value(s) in the output. That is a standard note and has nothing to do with your output order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would suggest actually adding the results of those WhichC and WhichN calculations as variables and use order by those calculated variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or possibly create an actual date value and sort by that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without actually seeing some input values and what you expect the order for the output just guessing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2023 21:52:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-sql-whichn/m-p/865807#M341915</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-03-22T21:52:32Z</dc:date>
    </item>
    <item>
      <title>Re: SAS sql whichn</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-sql-whichn/m-p/865929#M341973</link>
      <description>&lt;P&gt;Thanks Tom, this worked as well. I realized what the issue was, the original code was ordering the table correctly, but it seemed like there missing weeks for one of the seasons so maybe that is why I was getting the note?&amp;nbsp; In any case, I learned two ways to sort it.&amp;nbsp; appreciate it. ER.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 13:45:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-sql-whichn/m-p/865929#M341973</guid>
      <dc:creator>eramirez</dc:creator>
      <dc:date>2023-03-23T13:45:38Z</dc:date>
    </item>
    <item>
      <title>Re: SAS sql whichn</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-sql-whichn/m-p/865931#M341974</link>
      <description>thank you! I realized that some weeks in one of seasons were missing so the order was not going to appear the way I expected. Otherwise, the custom order worked. appreciate it. ER</description>
      <pubDate>Thu, 23 Mar 2023 13:47:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-sql-whichn/m-p/865931#M341974</guid>
      <dc:creator>eramirez</dc:creator>
      <dc:date>2023-03-23T13:47:09Z</dc:date>
    </item>
  </channel>
</rss>

