lesson09 - Lesson 9 Topics Restructuring datasets C&S...

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

View Full Document Right Arrow Icon
Lesson 9 - Topics Restructuring datasets LSB: 6:14 Programs 17-19 in course notes
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
LIBNAME class '~/PH6420/2011/Data' ; DATA temp; SET class.tomhsp (KEEP=ptid clinic sex wtbl wt12 sbpbl sbp12 ); wtchg = wt12 - wtbl; sbpchg = sbp12 - sbpbl; RUN ; * Find out names of output; ods trace on / listing ; ods output pearsoncorr = correlation_stats; proc corr data =temp; var wtchg sbpchg; run ; ods output close ; ods output parameterestimates = reg_coef; proc reg data =temp; model sbpchg = sex wtchg; run ; ods output close ; proc print data =correlation_stats; proc print data =reg_coef; Capturing SAS Output into SAS Dataset
Background image of page 2
Two Structures for Data A001 125 130 140 01/15/95 07/15/95 01/15/96 A001 125 01/15/95 A001 130 07/15/95 A001 140 01/15/96 3 obs/patient Advantages for each format
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
Restructure Data Read in multiple observations per patient and write out one observation per patient Read in one observation per patient and write out multiple observations per patient
Background image of page 4
Restructuring Datasets Data for a patient sometimes comes as multiple observations ptid visit date weight id1 0 01/15/98 200 id1 3 04/18/98 190 id1 6 07/13/98 196 id2 0 11/14/98 165 id2 3 02/18/99 160 id2 6 05/13/99 155 Wish to collapse data so all information for a patient is contained on 1 observation
Background image of page 5

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

View Full Document Right Arrow Icon
Program 17 Collapsing multiple observations per patient to one observation per patient DATA visit; INFILE ‘C:\SAS_Files\multrec.data' OBS = 21 ; INPUT ptid $ visit group weight sbp; RUN ; PROC SORT DATA =visit; BY ptid visit; PROC PRINT DATA = visit ; TITLE 'Display of Mult obs/patient dataset ' ; RUN ;
Background image of page 6
Display of Mult obs/patient dataset Obs ptid visit group weight sbp 1 A00083 3 2 128 112 2 A00083 6 2 124 105 3 A00083 9 2 125 113 4 A00083 12 2 125 113 5 A00301 3 6 205 118 6 A00301 6 6 209 109 7 A00312 3 3 134 127 8 A00312 6 3 134 129 9 A00312 9 3 132 135 10 A00312 12 3 131 113
Background image of page 7

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

View Full Document Right Arrow Icon
Want dataset to look like this : Obs ptid group wt3 wt6 wt9 wt12 sbp3 sbp6 sbp9 sbp12 1 A00083 2 128 124 125 125 112 105 113 113 2 A00301 6 205 209 . . 118 109 . . 3 A00312 3 134 134 132 131 127 129 135 113 4 A00354 3 149 145 142 140 124 139 124 116 5 A00400 5 190 . . . 121 . . . 6 A00504 4 184 186 176 181 112 124 118 115 7 A00608 2 . 188 189 . . 130 114 . Several ways to do this.
Background image of page 8
/******************************************************* Here is one solution. Separate datasets are created for each visit and then merged. The visit-varying variables are renamed using PROC DATASETS. ********************************************************/ DATA visit3 visit6 visit9 visit12; SET visit; ; if visit = 3 then output visit3; else if visit = 6 then output visit6; else if visit = 9 then output visit9; else if visit = 12 then output visit12; run ; These all have one row per id
Background image of page 9

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

View Full Document Right Arrow Icon
* Need to rename variables to have unique names; PROC DATASETS ; MODIFY visit3; RENAME weight = weight3 sbp = sbp3; MODIFY visit6; RENAME weight = weight6 sbp = sbp6; MODIFY visit9; RENAME weight = weight9 sbp = sbp9; MODIFY visit12;
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 35

lesson09 - Lesson 9 Topics Restructuring datasets C&S...

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

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