CH5 - STAT1303A Data Management 5. Creating New Var. and...

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

View Full Document Right Arrow Icon
STAT1303A Data Management 5. Creating New Var. and SAS Functions 5 Creating New Variables and SAS Functions In previous chapters, we have used the SAS procedures to data summarization in which simple calculation is performed. In this chapter, the creation of new variables and the SAS functions are discussed because more complicated calculation is necessary for realistic data management and analysis. 5.1 Assignment Statement To create or modify SAS variables, an assignment statement is used in Data Step. variable = expression; The, the variable receives the new information and the required information / data, we must enclose the data in quotation marks or double quotation marks. To statement LENGTH should be used. Example 5.1. * Example 5.1 assignment statement; libname ch5 &D:\temp&; data trade; set ch5.trade1; total=import+retained+reexport; run; proc print; run; Obs year category import retained reexport total 1 1995 1 61158 42953 19534 123645 2 1995 2 562415 142897 546247 1251559 3 1995 3 543075 225708 336550 1105333 ... total = import + retained + reexport; Then, a new variable TOTAL which is the sum of IMPORT, RETAINED and REEXPORT, is created. HKU STAT1303A (2009-10, Semester 1) 5 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
5. Creating New Var. and SAS Functions 5.2 Numeric Assignment Operators and Functions 5.2.1 Numeric Variables A numeric variable is a variable whose values are numbers. In SAS, numeric variables of mathematical operations on numeric variables can be performed by SAS and SAS functions extend the mathematical calculation capability for numeric expressions. 5.2.2 Arithmetic Operators Operation Symbol Example Addition + x = y + z Subtraction x = y z Multiplication ± x = y ± z Division = x = y=z Exponentiation ±± x = y ± ± z The order of operations in arithmetic expressions follows rules in mathematical expression ² Parentheses > exponentiation > multiplication and division > addition and subtraction. 5.2.3 Missing values in numeric variables By default, the missing value in data lines (raw data) are represented by a period (.). In an expression, a missing numeric values is represented by a period, e.g. export = .; means that a numeric variable EXPORT is created and initialized with missing value. In the output of PROC, a missing numeric value is printed as a period (by default). For some SAS PROCs, missing numeric value is removed from analysis while some of them do not. Indeed, some of them may have options to choose from. HKU STAT1303A (2009-10, Semester 1)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 9

CH5 - STAT1303A Data Management 5. Creating New Var. and...

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

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