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;

sas-innovate-2024.png

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.

 

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