<?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 the highest result needs to be selected if ID has more than one value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/the-highest-result-needs-to-be-selected-if-ID-has-more-than-one/m-p/979106#M378734</link>
    <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Appreciate your input.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have data like below.&lt;BR /&gt;It has ID and their PDL1 values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data have;&lt;BR /&gt;Input ID $8. PDL1 $8.;&lt;BR /&gt;cards;&lt;BR /&gt;E0401004 0&lt;BR /&gt;E0401004 &amp;lt;1&lt;BR /&gt;E0402001 &amp;lt;1&lt;BR /&gt;E0402001 80&lt;BR /&gt;E0403018 70&lt;BR /&gt;E0403018 80&lt;BR /&gt;E0403018 95&lt;BR /&gt;E0403503 N/A&lt;BR /&gt;E0403503 0&lt;BR /&gt;E1005513 12&lt;BR /&gt;E1005513 5&lt;BR /&gt;;&lt;BR /&gt;Run;&lt;/P&gt;
&lt;P&gt;We need to add priority variable as follows.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;if PDL1 = "N/A" then priority=0;&lt;BR /&gt;if PDL1 in ('0', '&amp;lt;1') then priority=1; &lt;BR /&gt;if 1&amp;lt;=PDL1&amp;lt;=49 then priority=2; &lt;BR /&gt;if 50&amp;lt;=PDL1 then priority=3;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If a patient has more than one result, the highest result needs to be selected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want&lt;/P&gt;
&lt;TABLE width="228"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="66"&gt;ID&lt;/TD&gt;
&lt;TD width="98"&gt;Expected PDL1&lt;/TD&gt;
&lt;TD width="64"&gt;Priority&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;E0401004&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;E0402001&lt;/TD&gt;
&lt;TD&gt;80&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;E0403018&lt;/TD&gt;
&lt;TD&gt;95&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;E0403503&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;E1005513&lt;/TD&gt;
&lt;TD&gt;12&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
    <pubDate>Wed, 19 Nov 2025 11:29:57 GMT</pubDate>
    <dc:creator>anandrc</dc:creator>
    <dc:date>2025-11-19T11:29:57Z</dc:date>
    <item>
      <title>the highest result needs to be selected if ID has more than one value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/the-highest-result-needs-to-be-selected-if-ID-has-more-than-one/m-p/979106#M378734</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Appreciate your input.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have data like below.&lt;BR /&gt;It has ID and their PDL1 values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data have;&lt;BR /&gt;Input ID $8. PDL1 $8.;&lt;BR /&gt;cards;&lt;BR /&gt;E0401004 0&lt;BR /&gt;E0401004 &amp;lt;1&lt;BR /&gt;E0402001 &amp;lt;1&lt;BR /&gt;E0402001 80&lt;BR /&gt;E0403018 70&lt;BR /&gt;E0403018 80&lt;BR /&gt;E0403018 95&lt;BR /&gt;E0403503 N/A&lt;BR /&gt;E0403503 0&lt;BR /&gt;E1005513 12&lt;BR /&gt;E1005513 5&lt;BR /&gt;;&lt;BR /&gt;Run;&lt;/P&gt;
&lt;P&gt;We need to add priority variable as follows.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;if PDL1 = "N/A" then priority=0;&lt;BR /&gt;if PDL1 in ('0', '&amp;lt;1') then priority=1; &lt;BR /&gt;if 1&amp;lt;=PDL1&amp;lt;=49 then priority=2; &lt;BR /&gt;if 50&amp;lt;=PDL1 then priority=3;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If a patient has more than one result, the highest result needs to be selected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want&lt;/P&gt;
&lt;TABLE width="228"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="66"&gt;ID&lt;/TD&gt;
&lt;TD width="98"&gt;Expected PDL1&lt;/TD&gt;
&lt;TD width="64"&gt;Priority&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;E0401004&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;E0402001&lt;/TD&gt;
&lt;TD&gt;80&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;E0403018&lt;/TD&gt;
&lt;TD&gt;95&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;E0403503&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;E1005513&lt;/TD&gt;
&lt;TD&gt;12&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Wed, 19 Nov 2025 11:29:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/the-highest-result-needs-to-be-selected-if-ID-has-more-than-one/m-p/979106#M378734</guid>
      <dc:creator>anandrc</dc:creator>
      <dc:date>2025-11-19T11:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: the highest result needs to be selected if ID has more than one value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/the-highest-result-needs-to-be-selected-if-ID-has-more-than-one/m-p/979109#M378735</link>
      <description>&lt;P&gt;Once your prio logic is in place, you can use SQL, something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   select id, pdl1, priority
      from have
      group by id
      having max(priority) = priority
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Nov 2025 11:45:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/the-highest-result-needs-to-be-selected-if-ID-has-more-than-one/m-p/979109#M378735</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2025-11-19T11:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: the highest result needs to be selected if ID has more than one value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/the-highest-result-needs-to-be-selected-if-ID-has-more-than-one/m-p/979110#M378736</link>
      <description>&lt;P&gt;Easy to solve after PDL1 has been converted to a numeric variable.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    invalue pdl2num
        "N/A" = .
        "&amp;lt;1" = 0
        other = [best.]
    ;
    value pdlprio
        . = 0
        0 = 1
        1 - 49 = 3
        50 - HIGH = 4
    ;
run;

data fixed;
    set have(rename= (pdl1 = pdl1_str));

    pdl1 = input(pdl1_str, pdl2num.);
    priority = put(pdl1, pdlprio.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Use the code posted by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13674"&gt;@LinusH&lt;/a&gt;&amp;nbsp;to get the final result.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Nov 2025 11:55:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/the-highest-result-needs-to-be-selected-if-ID-has-more-than-one/m-p/979110#M378736</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2025-11-19T11:55:36Z</dc:date>
    </item>
    <item>
      <title>Re: the highest result needs to be selected if ID has more than one value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/the-highest-result-needs-to-be-selected-if-ID-has-more-than-one/m-p/979119#M378741</link>
      <description>&lt;P&gt;&lt;BR /&gt;Thanks for the reply.&lt;/P&gt;
&lt;P&gt;Expected PDL1 variable result - only when there is more than one value of any combination (&amp;lt;1, 0)&amp;nbsp; the results should display &amp;lt;1 and not 0.&lt;BR /&gt;Ideally per logic, its 0 because that higher than &amp;lt;1 but our report need to show as &amp;lt;1.&lt;/P&gt;
&lt;P&gt;Sorry for the confusion.&lt;BR /&gt;So want the final dataset to show&lt;/P&gt;
&lt;P&gt;ID Expected PDL1&lt;BR /&gt;E0401004 &amp;lt;1&lt;BR /&gt;E0402001 80&lt;BR /&gt;E0403018 95&lt;BR /&gt;E0403503 0&lt;BR /&gt;E1005513 12&lt;/P&gt;</description>
      <pubDate>Wed, 19 Nov 2025 13:30:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/the-highest-result-needs-to-be-selected-if-ID-has-more-than-one/m-p/979119#M378741</guid>
      <dc:creator>anandrc</dc:creator>
      <dc:date>2025-11-19T13:30:56Z</dc:date>
    </item>
  </channel>
</rss>

