Handout03 - Class 3 1 Character data character variables 2...

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

View Full Document Right Arrow Icon
Class 3 1. Character data, character variables 2. SET and MERGE 3. DO-loops 4. Using output from a procedure: standardizing a variable 1 Data Types SAS distinguishes three types of data, and has different methods for dealing with each type. • Numeric data: integer or Foating point • Character data: any combination of letters, numbers, spaces, punctuation—character string • Date-time data: calendar dates and times of day 2
Background image of page 1

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

View Full Document Right Arrow Icon
Character variable is created by color = ’red’; or, color = ”red”; (matching single or double quotes). Within a character variable, SAS distinguishes upper and lower case: ”Female” is not equal to ”female” Numeric variables: missing is indicated by a period, dbp = . Character variables: missing is indicated by no characters, color=” (two single quote marks with no space between them) 3 Length of character variables Data: x = 15, 16, 12, 4, 5, 3 data example; set X_data; if (x > 10) then size="big" ; else size="small" ; 4
Background image of page 2
Proc Print data = example; Obs X size 11 5 b i g 21 6 b i g 31 2 b i g 44 s m a 55 s m a 6 3 sma 5 SAS assigns a length (in characters) to each character variable. Default is 8. When you deFne a character variable in a data-step statement if (x > 10) then size="big" ; else size="small" ; SAS sets the variable-length equal to the length of the Frst value assigned. ±irst value is x=15 = ) size="big" = ) length of size is 3 6
Background image of page 3

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

View Full Document Right Arrow Icon
To prevent SAS from truncating, LENGTH statement sets the variable length: data example; set X_data; LENGTH size $5 ; $ indicates CHARACTER, number gives length if (x > 10) then size="big"; else size="small"; Obs x size 11 5 b i g 21 6 b i g 31 2 b i g 44 s m a l l 55 s m a l l 6 3 small See LSB §10.13 7 Pasting character variables together || or !!
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 12

Handout03 - Class 3 1 Character data character variables 2...

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

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