<?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: Code is changing the values of a variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Code-is-changing-the-values-of-a-variable/m-p/954229#M372706</link>
    <description>I think you just want:&lt;BR /&gt;IF LAST.patient;&lt;BR /&gt;&lt;BR /&gt;...rather than FIRST.</description>
    <pubDate>Fri, 20 Dec 2024 01:15:40 GMT</pubDate>
    <dc:creator>quickbluefish</dc:creator>
    <dc:date>2024-12-20T01:15:40Z</dc:date>
    <item>
      <title>Code is changing the values of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Code-is-changing-the-values-of-a-variable/m-p/954223#M372702</link>
      <description>&lt;P&gt;I'm trying to subset a dataset into the greatest value of a single outcome within the multiple visits of each patient, so that each patient is listed once with his/her "best response":&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SORT DATA=Rank;&lt;/P&gt;&lt;P&gt;BY Patient Response;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;DATA Best_Response;&lt;/P&gt;&lt;P&gt;SET Rank;&lt;/P&gt;&lt;P&gt;BY Patient;&lt;/P&gt;&lt;P&gt;IF FIRST.Patient = 1;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As written, this code changes the value of "Best_Response" for every patient to the best value possible in the code. How do I fix? Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2024 00:25:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Code-is-changing-the-values-of-a-variable/m-p/954223#M372702</guid>
      <dc:creator>Newtrix</dc:creator>
      <dc:date>2024-12-20T00:25:28Z</dc:date>
    </item>
    <item>
      <title>Re: Code is changing the values of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Code-is-changing-the-values-of-a-variable/m-p/954224#M372703</link>
      <description>&lt;P&gt;That code is NOT changing the values of any variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What it is doing is reducing the number of observations per PATIENT to only one.&amp;nbsp; The observation with the minimum value of RESPONSE for that patient.&amp;nbsp; So if PATIENT=1 had three observations with RESPONSE values of 2, 7 and 9 then the output dataset will only keep the observation where RESPONSE was 2 since it would be the first one for PATIENT=1 after the sort.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;title;
data have;
  input patient response other;
cards;
1 2 10
1 7 4
1 9 50
2 1 1
3 9 99
3 8 88
3 7 77
;

proc sort;
  by patient response;
run;

proc print;
run;

data want;
  set have ;
  by patient;
  if first.patient;
run;

proc print;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1734655068796.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103242i5E17534285EB0D09/image-size/large?v=v2&amp;amp;px=999" role="button" title="Tom_0-1734655068796.png" alt="Tom_0-1734655068796.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;What is it that you are trying to do?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2024 00:38:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Code-is-changing-the-values-of-a-variable/m-p/954224#M372703</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-12-20T00:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: Code is changing the values of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Code-is-changing-the-values-of-a-variable/m-p/954229#M372706</link>
      <description>I think you just want:&lt;BR /&gt;IF LAST.patient;&lt;BR /&gt;&lt;BR /&gt;...rather than FIRST.</description>
      <pubDate>Fri, 20 Dec 2024 01:15:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Code-is-changing-the-values-of-a-variable/m-p/954229#M372706</guid>
      <dc:creator>quickbluefish</dc:creator>
      <dc:date>2024-12-20T01:15:40Z</dc:date>
    </item>
  </channel>
</rss>

