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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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