Week2 Flashcards
What are some system options?
Nodate
Nocenter
Center
OBS =n|min|max - limit the number of observations read by sas
Firstobs = where you want to start
LS-line size or number of columns
Ps- page size or number of rows
Pageno =1
Global statements
Sets values and attributes for all output created after global statement specified. I will stay until overridden.
Examples: TITLE, OPTIONS, FOOTNOTE
OBS
OBS= #of obs
OBS=max
FIRSTOBS=
Creating and redefining variables
New variable = old variable expression
Can use numeric operators
EQ, NE, LT, GT, LE, GE
Property use of listing index variables with OF
(X1+x2+x3)
SUM(x1, x2, x3)
Sum(OF x1 x2 x3)
Sum(OF x1-x3)
Sum(OF x1- -y1) different indexes
You don’t need commas after OF
Functions
Sum, mean, sqrt, abs, upcase, lowcase, int, round, floor, ceil, log, log10
SUBSTR
Used to pars a character string from a character variable.
SUBSTR(charvar, initial position, total characters)
PHONE=(502) 852-2222
AREA = SUBSTR(PHONE, 2, 3)
Common statement options
Label, keep, drop, rename, position
DATA dataset (option= x)
Set data (rename=(old=new);
PROC SORT
Use BY statement and list variable
Good to use an OUT statement
Auto is ascending
Removing duplicates
NODUP- used in statement option in proxy removes unwanted duplicates
Uses BY_ALL_ it removes fully duplicated observations
NODUPKEY remove partially duplicated observations of the BY variable
Combining data
Concatenation: SET data1 data2
interleaving: SET data1 data2
BY var
Best use when both data sets have the same variables, but not the same records
Merging
Simple merges
Unmatched merge – ation from two or more data sets are combined, one to one
Matched merge - matching values of BY variables
Sort first!
UPdATE
IN
The in option creates a variable indicating what data sets contribute to forming the observation in the final data set. gets the value of one if it did in zero if it did not.
IN=A IN=B
IF A=B if A and B are in both data sets
IF=B leaves out nonmatching records from A