BookmarkSubscribeRSS Feed
DocStudent
Calcite | Level 5

I'm creating a model where I want to use the highest level of education earned between the mother or the father (whichever one has the highest level of education).  The variable for mother and father education is measured continuously, with the higher numbers representing higher levels of education. However, I did create dummy variables also for different categories to combine some levels.  (Not that they have to stay combined, it was a preference at the time.) Does anyone know how to create a variable that would represent the highest level between the two? 

2 REPLIES 2
PGStats
Opal | Level 21

Function max(x, y) returns the maximun value between x and y.

PG
DanielLangley
Quartz | Level 8

You should really post an example of the data you have and the data you want.

Regardless I have made a major assumption about the data you have  and the data you want and the below code should work for that data.

 

data have;
input ID MotherEducation FatherEducation;
DATALINES;
1 0 1
2 1 2
3 2 2
4 2 1
5 2 0
;
run;

Data Want;
	SET have;
	MaxEd = Max(MotherEducation,FatherEducation);
run;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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