<?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: Retaining only the lowest price per item number in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Retaining-only-the-lowest-price-per-item-number/m-p/911167#M359301</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/434710"&gt;@Cheesiepoof05&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello, I have a spreadsheet with many columns but want to limit it down based on two fields.&amp;nbsp; I'm trying to only retain the lowest "Price" per "Item_ID".&amp;nbsp; Some Item_IDs will have multiple records with the same lowest price so I don't care which of the records with lowest price it keeps, but just need one of them.&amp;nbsp; Example below with the kept records in yellow.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cheesiepoof05_0-1704896104926.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92428iC9837E4B62F15CE4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cheesiepoof05_0-1704896104926.png" alt="Cheesiepoof05_0-1704896104926.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Example of your SAS data set. From you description of "many columns" one suspects that this is going to be a couple steps depending on what is in those columns.&lt;/P&gt;
&lt;P&gt;Showing an example with two columns when your problem states many obfuscates details that will be needed to solve the complete problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the &amp;lt;/&amp;gt; icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
    <pubDate>Wed, 10 Jan 2024 16:37:04 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2024-01-10T16:37:04Z</dc:date>
    <item>
      <title>Retaining only the lowest price per item number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retaining-only-the-lowest-price-per-item-number/m-p/911134#M359287</link>
      <description>&lt;P&gt;Hello, I have a spreadsheet with many columns but want to limit it down based on two fields.&amp;nbsp; I'm trying to only retain the lowest "Price" per "Item_ID".&amp;nbsp; Some Item_IDs will have multiple records with the same lowest price so I don't care which of the records with lowest price it keeps, but just need one of them.&amp;nbsp; Example below with the kept records in yellow.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cheesiepoof05_0-1704896104926.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92428iC9837E4B62F15CE4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cheesiepoof05_0-1704896104926.png" alt="Cheesiepoof05_0-1704896104926.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2024 14:16:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retaining-only-the-lowest-price-per-item-number/m-p/911134#M359287</guid>
      <dc:creator>Cheesiepoof05</dc:creator>
      <dc:date>2024-01-10T14:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining only the lowest price per item number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retaining-only-the-lowest-price-per-item-number/m-p/911135#M359288</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have;
class item_id;
var price;
output out=want min()=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
  select
    item_id,
    min(price)
  from have
  group by item_id
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Jan 2024 14:20:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retaining-only-the-lowest-price-per-item-number/m-p/911135#M359288</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-01-10T14:20:36Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining only the lowest price per item number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retaining-only-the-lowest-price-per-item-number/m-p/911167#M359301</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/434710"&gt;@Cheesiepoof05&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello, I have a spreadsheet with many columns but want to limit it down based on two fields.&amp;nbsp; I'm trying to only retain the lowest "Price" per "Item_ID".&amp;nbsp; Some Item_IDs will have multiple records with the same lowest price so I don't care which of the records with lowest price it keeps, but just need one of them.&amp;nbsp; Example below with the kept records in yellow.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cheesiepoof05_0-1704896104926.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92428iC9837E4B62F15CE4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cheesiepoof05_0-1704896104926.png" alt="Cheesiepoof05_0-1704896104926.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Example of your SAS data set. From you description of "many columns" one suspects that this is going to be a couple steps depending on what is in those columns.&lt;/P&gt;
&lt;P&gt;Showing an example with two columns when your problem states many obfuscates details that will be needed to solve the complete problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the &amp;lt;/&amp;gt; icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2024 16:37:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retaining-only-the-lowest-price-per-item-number/m-p/911167#M359301</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-01-10T16:37:04Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining only the lowest price per item number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retaining-only-the-lowest-price-per-item-number/m-p/911174#M359305</link>
      <description>&lt;P&gt;Looks like you sorted the data&amp;nbsp; (And hopefully you have moved it out of a Spreadsheet and into an actual dataset) so a simple data step with BY group processing should work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  by item_id price;
  if first.item_id;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If some of the prices are missing then also add a WHERE statement to ignore those observations since missing values are smaller than any actual value.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where not missing(price);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Jan 2024 17:16:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retaining-only-the-lowest-price-per-item-number/m-p/911174#M359305</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-01-10T17:16:02Z</dc:date>
    </item>
  </channel>
</rss>

