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?
Function max(x, y) returns the maximun value between x and y.
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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.