<?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 select first occurrence, ignore duplicates, categorize groups without occurrence? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-first-occurrence-ignore-duplicates-categorize/m-p/884223#M349308</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/438491"&gt;@JMagenta&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Sorry for the confusion. I needed a solution not a troll. Thank you though.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Just explain what you want more clearly.&amp;nbsp; &amp;nbsp; For example one question is what happens to the observations before the first observation that is COOL?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Providing working data steps will make it easier for others to help you.&amp;nbsp; It also make it clearer what your data actually looks like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Providing the complete expected output (again as working data step) will make it easier to test whether suggested code could work.&lt;/P&gt;</description>
    <pubDate>Mon, 10 Jul 2023 16:38:40 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-07-10T16:38:40Z</dc:date>
    <item>
      <title>How to select first occurrence, ignore duplicates, categorize groups without occurrence?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-first-occurrence-ignore-duplicates-categorize/m-p/884200#M349294</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data readin; &lt;BR /&gt;input ID Name Status; cards; &lt;BR /&gt;1 David Cool &lt;BR /&gt;1 David Cool &lt;BR /&gt;1 David Not Cool &lt;BR /&gt;2 Sam Warm &lt;BR /&gt;2 Sam Lukewarm &lt;BR /&gt;3 Bane Cool &lt;BR /&gt;4 Mary Warm &lt;BR /&gt;3 Bane Not Cool &lt;BR /&gt;5 Dane Cool &lt;BR /&gt;6 Jenny Cool &lt;BR /&gt;7 Ken Not Cool&lt;BR /&gt;8 Simran Warm &lt;BR /&gt;9 Priya Hot ; run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;And for each group I want to select the first occurrence of STATUS where the value is "Cool" . I want ignore duplicate values of "Cool",&amp;nbsp; categorize the other values in the group with another variable, Bingo, as&amp;nbsp; "Other Statuses for this person".&amp;nbsp; I want to also categorize other groups without the value of "Cool" as "Other Statuses".&amp;nbsp; If possible I would like one data step or proc sql step for this.&amp;nbsp; I know I need to sort the data too.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want the data to look something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="width: 300px;" width="300"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH width="40px"&gt;ID&lt;/TH&gt;
&lt;TH width="52.2px"&gt;Name&lt;/TH&gt;
&lt;TH width="40px"&gt;Status&lt;/TH&gt;
&lt;TH width="40px"&gt;Bingo&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR class="tg-even"&gt;
&lt;TD width="40px"&gt;1&lt;/TD&gt;
&lt;TD width="52.2px"&gt;David&lt;/TD&gt;
&lt;TD width="40px"&gt;Cool&lt;/TD&gt;
&lt;TD width="40px"&gt;Cool&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="40px"&gt;1&lt;/TD&gt;
&lt;TD width="52.2px"&gt;David&lt;/TD&gt;
&lt;TD width="40px"&gt;
&lt;P&gt;Cool&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="40px"&gt;Other Status for this person&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;David&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;Not Cool&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;Other Status for this person&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;Sam&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;Warm&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;Other Statuses&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can achieve this? Any help with this is welcome and much appreciated!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;J&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 14:27:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-first-occurrence-ignore-duplicates-categorize/m-p/884200#M349294</guid>
      <dc:creator>JMagenta</dc:creator>
      <dc:date>2023-07-10T14:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to select first occurrence, ignore duplicates, categorize groups without occurrence?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-first-occurrence-ignore-duplicates-categorize/m-p/884202#M349295</link>
      <description>&lt;P&gt;I am not sure I understand you description of the logic used. I think more details would be helpful. I think a complete list of the desired output, for all IDs would be helfpul; you only show outputs for IDs 1 and 2, I want to see the desired output for IDs 1 to 9.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Furthermore, your code does not work, see the screen capture below, and I request that you fix it.&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="PaigeMiller_0-1688999716004.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/85693i77CC0C108BE7DC82/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PaigeMiller_0-1688999716004.png" alt="PaigeMiller_0-1688999716004.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 14:36:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-first-occurrence-ignore-duplicates-categorize/m-p/884202#M349295</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-07-10T14:36:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to select first occurrence, ignore duplicates, categorize groups without occurrence?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-first-occurrence-ignore-duplicates-categorize/m-p/884219#M349304</link>
      <description>Sorry for the confusion. I needed a solution not a troll. Thank you though.</description>
      <pubDate>Mon, 10 Jul 2023 16:24:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-first-occurrence-ignore-duplicates-categorize/m-p/884219#M349304</guid>
      <dc:creator>JMagenta</dc:creator>
      <dc:date>2023-07-10T16:24:42Z</dc:date>
    </item>
    <item>
      <title>Select  first occurrence of value  then categorize other values  in group, categorize other groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-first-occurrence-ignore-duplicates-categorize/m-p/884222#M349312</link>
      <description>&lt;DIV class="lia-quilt-row lia-quilt-row-main"&gt;
&lt;DIV class="lia-quilt-column lia-quilt-column-24 lia-quilt-column-single lia-quilt-column-main"&gt;
&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-single"&gt;
&lt;DIV class="forum-topic-flex-article"&gt;
&lt;DIV class="forum-article"&gt;
&lt;DIV class="forum-post"&gt;
&lt;DIV id="bodyDisplay_14a54b5a87953e" class="lia-message-body lia-component-message-view-widget-body lia-component-body-signature-highlight-escalation lia-component-message-view-widget-body-signature-highlight-escalation"&gt;
&lt;DIV class="lia-message-body-content"&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a&amp;nbsp; data set, SAMPLE, here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="194px"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH width="52.775px" height="45px"&gt;ID&lt;/TH&gt;
&lt;TH width="68.7125px" height="45px"&gt;Name&lt;/TH&gt;
&lt;TH width="71.7125px" height="45px"&gt;Status&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR class="tg-even"&gt;
&lt;TD width="52.775px" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="68.7125px" height="30px"&gt;David&lt;/TD&gt;
&lt;TD width="71.7125px" height="30px"&gt;Cool&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="52.775px" height="85px"&gt;1&lt;/TD&gt;
&lt;TD width="68.7125px" height="85px"&gt;David&lt;/TD&gt;
&lt;TD width="71.7125px" height="85px"&gt;
&lt;P&gt;Cool&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="52.775px" height="85px"&gt;1&amp;nbsp;&lt;/TD&gt;
&lt;TD width="68.7125px" height="85px"&gt;David&lt;/TD&gt;
&lt;TD width="71.7125px" height="85px"&gt;
&lt;P&gt;Not Cool&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="52.775px" height="57px"&gt;2&amp;nbsp;&lt;/TD&gt;
&lt;TD width="68.7125px" height="57px"&gt;Sam&lt;/TD&gt;
&lt;TD width="71.7125px" height="57px"&gt;
&lt;P&gt;Warm&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&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;P&gt;For each group I want to select the first occurrence of STATUS where the value is "Cool"&amp;nbsp; and set my new variable Bingo as "Cool Person".&amp;nbsp; I want categorize&amp;nbsp; duplicate values of&amp;nbsp; "Cool" for the variable STATUS,&amp;nbsp; as well as other values of STATUS&amp;nbsp; in the group with the variable, Bingo, as&amp;nbsp; "Other Statuses for this person".&amp;nbsp; I want to also categorize other groups &lt;STRONG&gt;without&lt;/STRONG&gt; the value of "Cool"&amp;nbsp; for STATUS as "Other Statuses" for BINGO.&amp;nbsp; If possible I would like one data step or proc sql step for this.&amp;nbsp; I know I need to sort the data too.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want the data to look something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="297px"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH width="53.85px" height="45px"&gt;ID&lt;/TH&gt;
&lt;TH width="69.8125px" height="45px"&gt;Name&lt;/TH&gt;
&lt;TH width="72.8px" height="45px"&gt;Status&lt;/TH&gt;
&lt;TH width="99.7375px" height="45px"&gt;Bingo&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR class="tg-even"&gt;
&lt;TD width="53.85px" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="69.8125px" height="30px"&gt;David&lt;/TD&gt;
&lt;TD width="72.8px" height="30px"&gt;Cool&lt;/TD&gt;
&lt;TD width="99.7375px" height="30px"&gt;Cool Person&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="53.85px" height="85px"&gt;1&lt;/TD&gt;
&lt;TD width="69.8125px" height="85px"&gt;David&lt;/TD&gt;
&lt;TD width="72.8px" height="85px"&gt;
&lt;P&gt;Cool&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="99.7375px" height="85px"&gt;Other Status for this person&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="53.85px" height="85px"&gt;1&amp;nbsp;&lt;/TD&gt;
&lt;TD width="69.8125px" height="85px"&gt;David&lt;/TD&gt;
&lt;TD width="72.8px" height="85px"&gt;
&lt;P&gt;Not Cool&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="99.7375px" height="85px"&gt;Other Status for this person&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="53.85px" height="57px"&gt;2&amp;nbsp;&lt;/TD&gt;
&lt;TD width="69.8125px" height="57px"&gt;Sam&lt;/TD&gt;
&lt;TD width="72.8px" height="57px"&gt;
&lt;P&gt;Warm&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="99.7375px" height="57px"&gt;Other Statuses&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can achieve this? Any help with this is welcome and much appreciated!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;J&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="lia-quilt-row lia-quilt-row-footer"&gt;
&lt;DIV class="lia-quilt-column lia-quilt-column-24 lia-quilt-column-single lia-quilt-column-message-footer"&gt;
&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-single"&gt;
&lt;DIV class="message-actions-shelf"&gt;
&lt;DIV class="message-extra"&gt;
&lt;DIV class="AddMessageTags lia-message-tags lia-component-message-view-widget-tags"&gt;&lt;A id="showAddTag_14a54b5aa88150" class="lia-link-navigation add-tag-link" role="button" href="https://communities.sas.com/t5/SAS-Programming/How-to-select-first-occurrence-ignore-duplicates-categorize/td-p/884200#" aria-label="Add Tag..." target="_blank"&gt;Add Tags&lt;/A&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="message-actions"&gt;
&lt;DIV id="kudosButtonV2_14a54b5ae54591" class="KudosButton lia-button-image-kudos-wrapper lia-component-kudos-widget-button-version-3 lia-component-kudos-widget-button-horizontal lia-component-kudos-widget-button lia-component-kudos-action lia-component-message-view-widget-kudos-action" data-lia-kudos-id="884200"&gt;
&lt;DIV class="lia-button-image-kudos lia-button-image-kudos-horizontal lia-button-image-kudos-disabled lia-button-image-kudos-not-kudoed lia-button"&gt;
&lt;DIV class="lia-button-image-kudos-count"&gt;&lt;SPAN class="lia-link-navigation kudos-count-link lia-link-disabled" title="The total number of likes this post has received." aria-disabled="true"&gt;&lt;SPAN class="MessageKudosCount lia-component-kudos-widget-message-kudos-count"&gt;0&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="lia-button-image-kudos-label lia-component-kudos-widget-kudos-count-label"&gt;Likes&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV class="lia-button-image-kudos-give"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="accept"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="reply"&gt;&lt;SPAN class="lia-button-wrapper lia-button-wrapper-secondary"&gt;&lt;A id="link_1_14a54b5b01b3c8" class="lia-button lia-button-secondary reply-action-link lia-action-quick-reply lia-custom-event" href="https://communities.sas.com/t5/forums/replypage/board-id/programming/message-id/349294" rel="nofollow" target="_blank"&gt;Quick Reply&lt;/A&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 10 Jul 2023 16:37:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-first-occurrence-ignore-duplicates-categorize/m-p/884222#M349312</guid>
      <dc:creator>JMagenta</dc:creator>
      <dc:date>2023-07-10T16:37:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to select first occurrence, ignore duplicates, categorize groups without occurrence?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-first-occurrence-ignore-duplicates-categorize/m-p/884223#M349308</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/438491"&gt;@JMagenta&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Sorry for the confusion. I needed a solution not a troll. Thank you though.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Just explain what you want more clearly.&amp;nbsp; &amp;nbsp; For example one question is what happens to the observations before the first observation that is COOL?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Providing working data steps will make it easier for others to help you.&amp;nbsp; It also make it clearer what your data actually looks like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Providing the complete expected output (again as working data step) will make it easier to test whether suggested code could work.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 16:38:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-first-occurrence-ignore-duplicates-categorize/m-p/884223#M349308</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-07-10T16:38:40Z</dc:date>
    </item>
    <item>
      <title>Re: Select  first occurrence of value  then categorize other values  in group, categorize other grou</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-first-occurrence-ignore-duplicates-categorize/m-p/884228#M349313</link>
      <description>&lt;P&gt;Based on your requirements this seems like it gets you close.&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="Reeza_0-1689008921202.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/85700i1BE5E21FAD6555AA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Reeza_0-1689008921202.png" alt="Reeza_0-1689008921202.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/438491"&gt;@JMagenta&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;DIV class="lia-quilt-row lia-quilt-row-main"&gt;
&lt;DIV class="lia-quilt-column lia-quilt-column-24 lia-quilt-column-single lia-quilt-column-main"&gt;
&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-single"&gt;
&lt;DIV class="forum-topic-flex-article"&gt;
&lt;DIV class="forum-article"&gt;
&lt;DIV class="forum-post"&gt;
&lt;DIV id="bodyDisplay_14a54b5a87953e" class="lia-message-body lia-component-message-view-widget-body lia-component-body-signature-highlight-escalation lia-component-message-view-widget-body-signature-highlight-escalation"&gt;
&lt;DIV class="lia-message-body-content"&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a&amp;nbsp; data set, SAMPLE, here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="194px"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH width="52.775px" height="45px"&gt;ID&lt;/TH&gt;
&lt;TH width="68.7125px" height="45px"&gt;Name&lt;/TH&gt;
&lt;TH width="71.7125px" height="45px"&gt;Status&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR class="tg-even"&gt;
&lt;TD width="52.775px" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="68.7125px" height="30px"&gt;David&lt;/TD&gt;
&lt;TD width="71.7125px" height="30px"&gt;Cool&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="52.775px" height="85px"&gt;1&lt;/TD&gt;
&lt;TD width="68.7125px" height="85px"&gt;David&lt;/TD&gt;
&lt;TD width="71.7125px" height="85px"&gt;
&lt;P&gt;Cool&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="52.775px" height="85px"&gt;1&amp;nbsp;&lt;/TD&gt;
&lt;TD width="68.7125px" height="85px"&gt;David&lt;/TD&gt;
&lt;TD width="71.7125px" height="85px"&gt;
&lt;P&gt;Not Cool&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="52.775px" height="57px"&gt;2&amp;nbsp;&lt;/TD&gt;
&lt;TD width="68.7125px" height="57px"&gt;Sam&lt;/TD&gt;
&lt;TD width="71.7125px" height="57px"&gt;
&lt;P&gt;Warm&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&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;P&gt;For each group I want to select the first occurrence of STATUS where the value is "Cool"&amp;nbsp; and set my new variable Bingo as "Cool Person".&amp;nbsp; I want categorize&amp;nbsp; duplicate values of&amp;nbsp; "Cool" for the variable STATUS,&amp;nbsp; as well as other values of STATUS&amp;nbsp; in the group with the variable, Bingo, as&amp;nbsp; "Other Statuses for this person".&amp;nbsp; I want to also categorize other groups &lt;STRONG&gt;without&lt;/STRONG&gt; the value of "Cool"&amp;nbsp; for STATUS as "Other Statuses" for BINGO.&amp;nbsp; If possible I would like one data step or proc sql step for this.&amp;nbsp; I know I need to sort the data too.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want the data to look something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="297px"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH width="53.85px" height="45px"&gt;ID&lt;/TH&gt;
&lt;TH width="69.8125px" height="45px"&gt;Name&lt;/TH&gt;
&lt;TH width="72.8px" height="45px"&gt;Status&lt;/TH&gt;
&lt;TH width="99.7375px" height="45px"&gt;Bingo&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR class="tg-even"&gt;
&lt;TD width="53.85px" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="69.8125px" height="30px"&gt;David&lt;/TD&gt;
&lt;TD width="72.8px" height="30px"&gt;Cool&lt;/TD&gt;
&lt;TD width="99.7375px" height="30px"&gt;Cool Person&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="53.85px" height="85px"&gt;1&lt;/TD&gt;
&lt;TD width="69.8125px" height="85px"&gt;David&lt;/TD&gt;
&lt;TD width="72.8px" height="85px"&gt;
&lt;P&gt;Cool&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="99.7375px" height="85px"&gt;Other Status for this person&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="53.85px" height="85px"&gt;1&amp;nbsp;&lt;/TD&gt;
&lt;TD width="69.8125px" height="85px"&gt;David&lt;/TD&gt;
&lt;TD width="72.8px" height="85px"&gt;
&lt;P&gt;Not Cool&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="99.7375px" height="85px"&gt;Other Status for this person&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="53.85px" height="57px"&gt;2&amp;nbsp;&lt;/TD&gt;
&lt;TD width="69.8125px" height="57px"&gt;Sam&lt;/TD&gt;
&lt;TD width="72.8px" height="57px"&gt;
&lt;P&gt;Warm&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="99.7375px" height="57px"&gt;Other Statuses&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can achieve this? Any help with this is welcome and much appreciated!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;J&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="lia-quilt-row lia-quilt-row-footer"&gt;
&lt;DIV class="lia-quilt-column lia-quilt-column-24 lia-quilt-column-single lia-quilt-column-message-footer"&gt;
&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-single"&gt;
&lt;DIV class="message-actions-shelf"&gt;
&lt;DIV class="message-extra"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="message-actions"&gt;
&lt;DIV id="kudosButtonV2_14a54b5ae54591" class="KudosButton lia-button-image-kudos-wrapper lia-component-kudos-widget-button-version-3 lia-component-kudos-widget-button-horizontal lia-component-kudos-widget-button lia-component-kudos-action lia-component-message-view-widget-kudos-action" data-lia-kudos-id="884200"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="reply"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 17:09:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-first-occurrence-ignore-duplicates-categorize/m-p/884228#M349313</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-07-10T17:09:27Z</dc:date>
    </item>
    <item>
      <title>Re: Select  first occurrence of value  then categorize other values  in group, categorize other grou</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-first-occurrence-ignore-duplicates-categorize/m-p/884232#M349316</link>
      <description>&lt;P&gt;So reading between the lines it looks like ID is the variable that identifies the groups.&amp;nbsp; And it seems like you just want to set one of two values for the first observation of a group and then a constant value for all of the extra observations for the group. Also it seems from the values of this new variable that each group of observations represents a different person.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: "Cool Person" is not a valid variable name so let's just use NEW as the variable name.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input ID Name $ Status $10. ;
cards;
1 David Cool
1 David Cool
1 David Not Cool
2 Sam Warm
;

data want;
  set have ;
  by id;
  length NEW $30 ;
  if first.id then do;
    if status = 'Cool' then NEW = 'Cool Person';
    else NEW = 'Other statuses' ;
  end;
  else NEW = 'Other Status for this person' ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result.&lt;/P&gt;
&lt;PRE&gt;Obs    ID    Name     Status      NEW

 1      1    David    Cool        Cool Person
 2      1    David    Cool        Other Status for this person
 3      1    David    Not Cool    Other Status for this person
 4      2    Sam      Warm        Other statuses&lt;/PRE&gt;
&lt;P&gt;If the situation is more complicated then perhaps you could provide some more observations that have examples of those complications.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 17:33:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-first-occurrence-ignore-duplicates-categorize/m-p/884232#M349316</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-07-10T17:33:54Z</dc:date>
    </item>
    <item>
      <title>Re: Select  first occurrence of value  then categorize other values  in group, categorize other grou</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-first-occurrence-ignore-duplicates-categorize/m-p/884235#M349319</link>
      <description>&lt;P&gt;Thanks you,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will add one caveat, there is a parsing where statement that describes what the first occurrence should equal. It also includes a like statement. So I tried this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;data have ;
  input ID Name $ Status $10. ;
cards;
1 David Cool
1 David Cool
1 David Not Cool
2 Sam Warm
;

data want;
  set have ;
  by id;
  length NEW $30 ;
Where upcase(Status) like '&amp;amp;Cool&amp;amp;';
  if first.id then do;
    NEW = 'Cool Person';
    else do NEW = 'Other statuses' ;
  end;
  else NEW = 'Other Status for this person' ;
run;&lt;/LI-CODE&gt;
&lt;P&gt;But it didn't work.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 18:03:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-first-occurrence-ignore-duplicates-categorize/m-p/884235#M349319</guid>
      <dc:creator>JMagenta</dc:creator>
      <dc:date>2023-07-10T18:03:33Z</dc:date>
    </item>
    <item>
      <title>Re: Select  first occurrence of value  then categorize other values  in group, categorize other grou</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-first-occurrence-ignore-duplicates-categorize/m-p/884236#M349320</link>
      <description>&lt;P&gt;So this statement&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Where upcase(Status) like '&amp;amp;Cool&amp;amp;';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Can never work.&lt;/P&gt;
&lt;P&gt;If you convert STATUS to all uppercase then it could never have lower case letters o and l in it to match the condition.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The LOGIC is also wrong.&lt;/P&gt;
&lt;P&gt;If you only process the records with COOL in them then the groups that do not have any such records will disappear. Use the IF statement, not a WHERE statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to test if the letters COOL appear in a string you could use the INDEX() function or the FIND() function.&amp;nbsp; If you want to test if the word COOL appears in the string then use the INDEXW() or FINDW() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if index(lowcase(Status),'cool') then ....
if find(status,'cool','i') then ...
if indexw(lowcase(Status),'cool',' ') then ....
if findww(status,'cool',' ','i') then ...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But even that probably has a logic problem given your example data.&amp;nbsp; You had one record with STATUS='NOT COOL' which would match ALL of those tests, but looks to me like it means the opposite of COOL.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 18:16:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-first-occurrence-ignore-duplicates-categorize/m-p/884236#M349320</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-07-10T18:16:05Z</dc:date>
    </item>
  </channel>
</rss>

