Handout04 - Lecture 4 1. Editor keyboard shortcuts 2. More...

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

View Full Document Right Arrow Icon
Lecture 4 1. Editor keyboard shortcuts 2. More on merging 3. First and Last variables 4. Data set options 5. Finding unmatched or discrepant observations in a merge 6. Date and time data 1 Keyboard shortcuts: Tools > Options > Enhanced Editor Keys • Comment out lines of code using CTRL+/ • Uncomment using CTRL+SHIFT+/ • Create/remove bookmark: CTRL+F2 • Move to next/previous bookmark with F2/SHIFT+F2 • Create abbreviations using CTRL+SHIFT+A • Convert the selected text to lowercase CTRL+SHIFT+L, uppercase CTRL+SHIFT+U Select columns: hold ALT key while selecting Default list on course website (from SAS) 2
Background image of page 1

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

View Full DocumentRight Arrow Icon
Structural limitations in SAS processing 1. SAS can only work with data contained in a dataset. Data set: rows are observations, columns are variables. 2. SAS can only process one dataset at a time. To work with 2 datasets, combine them ( merge or set ). 3. Within a data step, SAS only works with one observation at a time. (There are ways to retain information from one observation to the next.) 3 More on MERGE 1. One-to-one merge: single observation for each ID in each data set (LSB §6.4) Data A Data B id color mass id mass pH 12 orange 3650 13 11267 7.8 13 blue 3877 14 3568 8.2 15 yellow 4103 15 4103 5.1 2. One-to-many merge : single observation ( xbar, SD ) in Frst data set merged with every observation in second data set (LSB §6.5) 4
Background image of page 2
Many-to-many MERGE: multiple observations per ID Want to merge two spreadsheets with clinical data recorded at each visit. Data E Data F id visit DBP id visit weight 101 1 77 101 1 145 101 2 75 101 2 149 .3 8 0 1 0 1 3 1 5 2 102 1 71 102 1 181 102 2 74 102 2 176 102 3 68 5 Let’s try code that worked before: proc sort data=E; by id; sort by ID frst proc sort data=F; by id; data G; merge EF; by id; SAS LOG NOTES: MERGE statement has more than one data set with repeats of BY values. There were 6 observations read from the data set WORK.E. There were 5 observations read from the data set WORK.F. The data set WORK.G has 7 observations and 4 variables. Extra observation? 6
Background image of page 3

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

View Full DocumentRight Arrow Icon
Data E Data F id visit DBP id visit weight 101 1 77 101 1 145 101 2 75 101 2 149 .3 8 0 1 0 1 3 1 5 2 102 1 71 102 1 181 102 2 74 102 2 176 102 3 68 Data G: Obs id visit dbp weight 1. 38 0 . 21 0 1 1 7 7 1 4 5 31 0 1 2 7 5 1 4 9 41 0 1 3 75 152 51 0 2 1 7 1 1 8 1 6 102 2 74 176 7 102 3 68 176 where did these come from? 7 Within each ID, SAS is merging without any matching variable. Sort by as many variables as needed to identify each observation. Then merge by all of them. Here, ID and visit are enough. Data E Data F id visit DBP id visit weight 101 1 77 101 1 145 101 2 75 101 2 149 8 0 1 0 1 3 1 5 2 102 1 71 102 1 181 102 2 74 102 2 176 102 3 68 8
Background image of page 4
proc sort data=E; by id visit; proc sort data=F; by id visit; data K; merge E F; by id visit; proc print data=K; Obs id visit dbp weight 1. 38 0 .
Background image of page 5

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

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

This note was uploaded on 11/21/2011 for the course PUBH 6470 taught by Professor Williamthomas during the Fall '11 term at University of Florida.

Page1 / 19

Handout04 - Lecture 4 1. Editor keyboard shortcuts 2. More...

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

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