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.

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 756 views
  • 0 likes
  • 3 in conversation