prg1c09 - 1 Chapter 9: Manipulating Data 9.1 Creating...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 Chapter 9: Manipulating Data 9.1 Creating Variables 9.2 Creating Variables Conditionally 9.3 Subsetting Observations 2 Chapter 9: Manipulating Data 9.1 Creating Variables 9.1 Creating Variables 9.2 Creating Variables Conditionally 9.3 Subsetting Observations 3 Objectives Create SAS variables with the assignment statement in the DATA step. Create data values by using operators including SAS functions. Subset variables by using the DROP and KEEP statements. Examine the compilation and execution phases of the DATA step when you read a SAS data set. Subset variables by using the DROP= and KEEP= options. (Self-Study) 3 4 Business Scenario A new SAS data set named Work.comp needs to be created by reading the orion.sales data set. Work.comp must include the following new variables: Bonus , which is equal to a constant 500 Compensation , which is the combination of the employee's salary and bonus BonusMonth , which is equal to the month that the employee was hired Work.comp must not include the Gender , Salary , Job_Title , Country , Birth_Date , and Hire_Date variables from orion.sales . 4 5 Business Scenario 5 Partial orion.sales Employee _ID First_ Name Last_ Name Gende r Salar y Job_ Title Countr y Birth_ Date Hire_ Date 120102 Tom Zhou M 10825 5 Sales Manager AU 3510 10744 120103 Wilson Dawes M 87975 Sales Manager AU-3996 5114 120121 Irenie Elvish F 26600 Sales Rep. II AU-5630 5114 Partial Work.comp Employee _ID First_ Name Last_ Name Bonu s Compensatio n Bonus Month 120102 Tom Zhou 500 108755 6 120103 Wilson Dawes 500 88475 1 120121 Irenie Elvish 500 27100 1 6 Assignment Statements (Review) Assignment statements are used in the DATA step to update existing variables or create new variables. 6 DATA output-SAS-data-set ; SET input-SAS-data-set ; variable = expression ; RUN; DATA output-SAS-data-set ; SET input-SAS-data-set ; variable = expression ; RUN; DATA output-SAS-data-set ; INFILE ' raw-data-file-name ' ; INPUT specifications ; variable = expression ; RUN; DATA output-SAS-data-set ; INFILE ' raw-data-file-name ' ; INPUT specifications ; variable = expression ; RUN; 7 Assignment Statements (Review) The assignment statement evaluates an expression and assigns the resulting value to a variable. General form of the assignment statement: variable names an existing or new variable. expression is a sequence of operands and operators that form a set of instructions that produce a value. 7 variable = expression ; variable = expression ; 8 Operands (Review) Operands are constants (character, numeric, or date) and variables (character or numeric). Examples: 8 NewSalary = 1.1 * Salary; Bonus = 500; Gender = 'M'; Hire_Date = '01APR2008'd; character constant date constant numeric constant variable 9 Operators (Review) Operators are symbols that represent an arithmetic calculation and SAS functions....
View Full Document

Page1 / 112

prg1c09 - 1 Chapter 9: Manipulating Data 9.1 Creating...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online