04-11-2017 02:29 PM
New SAS user here!
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?
Thanks the help!
04-11-2017 03:10 PM
proc sql; create table want as select *, max(term) as max_term from have group by student_id ; quit;
04-11-2017 03:26 PM
Is your Maxterm variable numeric or character? If character you my get unexpected results.
data junk; x='15'; output; x='5'; output; run; proc sql; select max(x) from junk; quit;
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.