BookmarkSubscribeRSS Feed
ethiveos
Calcite | Level 5

Hi,

 

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!

 

Student_IDTermMaxTerm
00000114
00000124
00000134
00000144
00000215
00000225
00000235
00000245
00000255
2 REPLIES 2
ballardw
Super User

Is your Maxterm variable numeric or character? If character you my get unexpected results.

Example:

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.

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 821 views
  • 0 likes
  • 3 in conversation