BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
graingerad12
Calcite | Level 5

I am trying to generate a new variable for years of education using the EDUC99 variable. The data set came with these formats already embedded in it. How would I go about creating a new variable(s) for years of education using the educ99 variable? 

 

value EDUC99_f
00 = "NIU"
01 = "No school completed"
04 = "1st-4th grade"
05 = "5th-8th grade"
06 = "9th grade"
07 = "10th grade"
08 = "11th grade"
09 = "12th grade, no diploma"
10 = "High school graduate, or GED"
11 = "Some college, no degree"
12 = "Associate degree, type of program not specified"
13 = "Associate degree, occupational program"
14 = "Associate degree, academic program"
15 = "Bachelors degree"
16 = "Masters degree"
17 = "Professional degree"
18 = "Doctorate degree"

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

For some of these the value for years would be moderately easy:

Values of 6, 7, 8 and 9 are pretty explicit.

No school looks like 0 years to me. Haven't a clue what NIU might be though from it's possition I might consider missing for years.

For others you make an assumption, 10 (High School or GED equiv) seem like 12 would be reasonable.

Associate academic degrees are typically considered "2 year" degrees, so High School + 2 = 14.

Bachelor's Degree are "4 year" so high school +4 = 16,

Master's are "2 year" so Bachelor + 2 = 18.

 

Other's you could use either a minimum, maximum or average value. The choice might well depend on the types of research questions that might be involved.

The basic approach is still IF-Then-Else or Select when.

If EDUC99 = 01 then Years = 0;

Else if EDUC99 = 02 then Years = 4; /*use the maximum possible*/

else if EDUC99 = 03 then Years = 8;

 

The SELECT construct is good for this type of list.

data want;
   set have;
   select (EDUC99);
      When(00) Year = .;
      When(01) Year = 0;
      When(04) Year = 4; 
      When(05) Year = 8; 
      When(06) Year = 9; 
      When(07) Year = 10; 
      When(08) Year = 11; 
      When(09) Year = 12; 
      When(10) Year = 12; 
      When(11) Year = 13; 
      When(12) Year = 14; 
      When(13) Year = 14; 
      When(14) Year = 14; 
      When(15) Year = 16; 
      When(16) Year = 18; 
      When(17) Year = 19; 
      When(18) Year = 20; 
      otherwise;
   end;
run;

Another option would be a custom informat but I'll leave that up to your research. See Proc Format Invalue.

 

 

You could have added this information to your previous question: select the gear icon and "edit post" to add this.

View solution in original post

2 REPLIES 2
ballardw
Super User

For some of these the value for years would be moderately easy:

Values of 6, 7, 8 and 9 are pretty explicit.

No school looks like 0 years to me. Haven't a clue what NIU might be though from it's possition I might consider missing for years.

For others you make an assumption, 10 (High School or GED equiv) seem like 12 would be reasonable.

Associate academic degrees are typically considered "2 year" degrees, so High School + 2 = 14.

Bachelor's Degree are "4 year" so high school +4 = 16,

Master's are "2 year" so Bachelor + 2 = 18.

 

Other's you could use either a minimum, maximum or average value. The choice might well depend on the types of research questions that might be involved.

The basic approach is still IF-Then-Else or Select when.

If EDUC99 = 01 then Years = 0;

Else if EDUC99 = 02 then Years = 4; /*use the maximum possible*/

else if EDUC99 = 03 then Years = 8;

 

The SELECT construct is good for this type of list.

data want;
   set have;
   select (EDUC99);
      When(00) Year = .;
      When(01) Year = 0;
      When(04) Year = 4; 
      When(05) Year = 8; 
      When(06) Year = 9; 
      When(07) Year = 10; 
      When(08) Year = 11; 
      When(09) Year = 12; 
      When(10) Year = 12; 
      When(11) Year = 13; 
      When(12) Year = 14; 
      When(13) Year = 14; 
      When(14) Year = 14; 
      When(15) Year = 16; 
      When(16) Year = 18; 
      When(17) Year = 19; 
      When(18) Year = 20; 
      otherwise;
   end;
run;

Another option would be a custom informat but I'll leave that up to your research. See Proc Format Invalue.

 

 

You could have added this information to your previous question: select the gear icon and "edit post" to add this.

Astounding
PROC Star

The first thing you would do is inspect the data.  Does the variable EDUC99 always take on values that appear on this scale, or are there other values possible?

 

Assuming that the value always appears on this scale, the next thing you would do is decide how many years of education you would like to assign for each of the categories.  There are no guidelines available from a program ... it's  your decision.

 

Once those decisions are in place, you could write a set of IF/THEN statements within a DATA step.  For example:

 

data want;

set have;

if EDUC99=1 then years_of_education=0;

else if EDUC99=8 then years_of_education=11;

else if EDUC99=9 then years_of_education=12;

else ...

run;

 

I'm assuming that EDUC99 is numeric, because it is connected to a numeric format (EDUC99_f).  But if it turns out to be character, slight changes might be needed.

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