DATA Step, Macro, Functions and more

generate a new variable

Reply
Occasional Contributor
Posts: 6

generate a new variable

Hello. I need help with an assignment that I am working on. The instructions are as follows:

 

Instructions:

Extract and download CPS data from IPUMS site onto your computer

https://cps.ipums.org/cps-action/variables/group

save the data file as SAS data set.

You will need to choose the following variables to include in your extract:

 

Person Record

 

Core Demographic Variables

AGE Age

SEX Gender

RACE Race

MARST Marital status

Ethnicity/Nativity Variables

NATIVITY Foreign birthplace or parentage

HISPAN Hispanic origin

Education Variables

EDUC99 Educational attainment, 1990 categories

Work Variables

WKSWORK1 Weeks worked last year

UHRSWORK Usual hours worked per week last year
UNION Union status
PTWEEKS Weeks working part time last year

Income Variables
INCWAGE Wage and salary income

 Process the CPS raw data using SAS to get it ready to analyze statistically. The following data processing steps are necessary before going on to step 3:

Drop observations for all non-wage earners.

Generate a new variable for the natural log of earnings from INCWAGE variable.

Generate a new variable for years of education using EDUC99 variable.

Generate a new variable for experience using AGE and EDUC99 variables.

Generate dummy variables for each of the following categories:

1) Gender

2) Race/Ethnicity

3) Nativity

4) Marital Status

5) Union Status

 

I need help with the question that says "generate a new variable for experience using AGE and EDUC99 variables. 

I have attached in a word document that SAS code that I have so far (which also defines all the variables).

Super User
Posts: 10,497

Re: generate a new variable

The techniques are exactly the same a mentioned in reponses to your other post. The "difference" is the assignment involves an "AND" condition:

In a datastep something like:

 

If age le 12 and EDUC99 = <somevalue> then Experience = <what ever you want to assign>;

 

Ranges considered and assigned should be part of the coursework involved.

 

Super User
Posts: 17,818

Re: generate a new variable

 

Please simplify your your code to only the relevant sections. 

 

This is your third question in the assignment so your basically asking each one at a time. Please attempt them first otherwise you won't learn anything.  Many people are more than happy to help but to get the most out of your course you should try and learn it. 

 

If you need learning resources - Google SAS UCLA Intro or see SAS Analytics U community forum for free training from SAS including ecourses and YouTube tutorials. 

 

Most of your assignment require if then statements. 

 

See this page on how they work. 

http://sphweb.bumc.bu.edu/otlt/MPH-Modules/BS/SAS/SAS-Basics1/SAS-Basics16.html

Ask a Question
Discussion stats
  • 2 replies
  • 286 views
  • 0 likes
  • 3 in conversation