<?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: Finding the max value of a variable for a given student ID (several rows per student) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-max-value-of-a-variable-for-a-given-student-ID/m-p/349226#M273521</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select *, max(term) as max_term
from have
group by student_id
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 11 Apr 2017 19:10:24 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2017-04-11T19:10:24Z</dc:date>
    <item>
      <title>Finding the max value of a variable for a given student ID (several rows per student)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-max-value-of-a-variable-for-a-given-student-ID/m-p/349217#M273520</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;New SAS user here!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to create a new variable based on the max of another variable associated with unique student IDs. Here's an example of the dataset. I'm trying to create the variable titled "MaxTerm". How would I specify that I'm looking for the max term for each student ID?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks the help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Student_ID&lt;/TD&gt;&lt;TD&gt;Term&lt;/TD&gt;&lt;TD&gt;MaxTerm&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;000001&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;000001&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;000001&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;000001&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;000002&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;000002&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;000002&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;000002&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;000002&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Tue, 11 Apr 2017 18:29:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-max-value-of-a-variable-for-a-given-student-ID/m-p/349217#M273520</guid>
      <dc:creator>ethiveos</dc:creator>
      <dc:date>2017-04-11T18:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the max value of a variable for a given student ID (several rows per student)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-max-value-of-a-variable-for-a-given-student-ID/m-p/349226#M273521</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select *, max(term) as max_term
from have
group by student_id
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Apr 2017 19:10:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-max-value-of-a-variable-for-a-given-student-ID/m-p/349226#M273521</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-04-11T19:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the max value of a variable for a given student ID (several rows per student)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-max-value-of-a-variable-for-a-given-student-ID/m-p/349230#M273522</link>
      <description>&lt;P&gt;Is your Maxterm variable numeric or character? If character you my get unexpected results.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;data junk;
   x='15';   output;
   x='5';    output;
run;

proc sql;
   select max(x)
   from junk;
quit;&lt;/PRE&gt;
&lt;P&gt;will return '5' as the maximum value because when comparing characters '5' is greater than '1'. The second character only comes into consideration when the first character is the same.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2017 19:26:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-max-value-of-a-variable-for-a-given-student-ID/m-p/349230#M273522</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-11T19:26:21Z</dc:date>
    </item>
  </channel>
</rss>

