DATA Step, Macro, Functions and more

Code to use in model for highest value

Reply
New User
Posts: 1

Code to use in model for highest value

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? 

Esteemed Advisor
Posts: 5,482

Re: Code to use in model for highest value

Posted in reply to DocStudent

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

PG
Occasional Contributor
Posts: 10

Re: Code to use in model for highest value

Posted in reply to DocStudent

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;
Ask a Question
Discussion stats
  • 2 replies
  • 81 views
  • 0 likes
  • 3 in conversation