<?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: How to delete top and bottom value within a group in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-delete-top-and-bottom-value-within-a-group/m-p/460523#M14283</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this way, first observation and last observation could be removed.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, it does not apply to each group, (other Season_Id, DY_TYP, ...)&lt;/P&gt;</description>
    <pubDate>Mon, 07 May 2018 17:29:32 GMT</pubDate>
    <dc:creator>Crubal</dc:creator>
    <dc:date>2018-05-07T17:29:32Z</dc:date>
    <item>
      <title>How to delete top and bottom value within a group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-delete-top-and-bottom-value-within-a-group/m-p/460511#M14281</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset called data_1, I would like to delete smallest on largest 'Room_Rate' from the data within each (Brand, HTL_CD, Prod_Class_Name, RM_NBR, RM_TYP, REF_ROOM_TYP, SEASON_ID, DY_TYP) combination.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the example as below (data_1), I would like to delete the first and last row.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Data_1.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/20399i659864CB94005E98/image-size/large?v=v2&amp;amp;px=999" role="button" title="Data_1.PNG" alt="Data_1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I used the following syntax:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc Sql;
		Create Table data_2 as select 
			 Brand 
			,Htl_Cd 
			,Prod_Class_Name 
			,RM_TYP 
			,REF_RM_TYP 
			,Season_Id 
			,DY_TYP 
			,Room_Rate 
		from data_1

		group by 1, 2, 3, 4, 5, 6, 7
		having Room_Rate &amp;gt; min(Room_Rate) and Room_Rate &amp;lt; max(Room_Rate)
		order by 1, 2, 3, 4, 5, 6, 7;
	Quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;First two rows are deleted as they both have 'Room_Rate' $93. as well as the last row with 'Room_Rate' $144.&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I do would like to keep one of the $93 row.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any way to handle it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 May 2018 17:00:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-delete-top-and-bottom-value-within-a-group/m-p/460511#M14281</guid>
      <dc:creator>Crubal</dc:creator>
      <dc:date>2018-05-07T17:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete top and bottom value within a group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-delete-top-and-bottom-value-within-a-group/m-p/460514#M14282</link>
      <description>&lt;P&gt;If you have sorted by room_rate, then just delete the first and last observation&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have end=eof;
    if _n_&amp;gt;1 and not eof then output;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 May 2018 17:13:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-delete-top-and-bottom-value-within-a-group/m-p/460514#M14282</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-05-07T17:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete top and bottom value within a group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-delete-top-and-bottom-value-within-a-group/m-p/460523#M14283</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this way, first observation and last observation could be removed.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, it does not apply to each group, (other Season_Id, DY_TYP, ...)&lt;/P&gt;</description>
      <pubDate>Mon, 07 May 2018 17:29:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-delete-top-and-bottom-value-within-a-group/m-p/460523#M14283</guid>
      <dc:creator>Crubal</dc:creator>
      <dc:date>2018-05-07T17:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete top and bottom value within a group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-delete-top-and-bottom-value-within-a-group/m-p/460524#M14284</link>
      <description>&lt;P&gt;You have NOT shown us data with groups. We can't read your mind. We can't provide a solution for data you didn't give us.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show us data with groups ... or simply change the solution I gave you to include FIRST. and LAST. logic, and the solution I gave works fine.&lt;/P&gt;</description>
      <pubDate>Mon, 07 May 2018 17:31:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-delete-top-and-bottom-value-within-a-group/m-p/460524#M14284</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-05-07T17:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete top and bottom value within a group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-delete-top-and-bottom-value-within-a-group/m-p/460562#M14288</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I modified it to :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	Data data_2;
		Set data_1; 
	     by  Brand 
			Htl_Cd 
			Prod_Class_Name 
			RM_TYP 
			REF_RM_TYP 
			Season_Id 
			DY_TYP;
		
		if not 
	   	first.Room_Rate
		and not 
                last.Room_Rate 
then output;
	Run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It didn't delete any&amp;nbsp;observation within each group. Anything wrong with it?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 07 May 2018 19:45:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-delete-top-and-bottom-value-within-a-group/m-p/460562#M14288</guid>
      <dc:creator>Crubal</dc:creator>
      <dc:date>2018-05-07T19:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete top and bottom value within a group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-delete-top-and-bottom-value-within-a-group/m-p/460563#M14289</link>
      <description>&lt;P&gt;use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FIRST.DY_TYP&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;LAST.DY_TYP&lt;/P&gt;</description>
      <pubDate>Mon, 07 May 2018 19:47:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-delete-top-and-bottom-value-within-a-group/m-p/460563#M14289</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-05-07T19:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete top and bottom value within a group</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-delete-top-and-bottom-value-within-a-group/m-p/460566#M14290</link>
      <description>&lt;P&gt;This is awesome, thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 May 2018 19:55:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-delete-top-and-bottom-value-within-a-group/m-p/460566#M14290</guid>
      <dc:creator>Crubal</dc:creator>
      <dc:date>2018-05-07T19:55:27Z</dc:date>
    </item>
  </channel>
</rss>

