# Handout06 - Lecture 6 1 Repetitive code 2 Arrays 3 Macros 1...

This preview shows pages 1–4. Sign up to view the full content.

Lecture 6 1. Repetitive code 2. Arrays 3. Macros 1 Repetitive code Often we want to repeat the same operation on a list of variables: compare 15 characteristics between 3 groups. Example. A nutrition clinical study compared three Fber supplements—barley, oats, control—in a parallel-arm design. Primary outcomes were changes from baseline to study midpoint and endpoint in blood lipids, stress markers, glucose and insulin. Outcome = change from baseline for each of 7 measurements. ¢ y = change in y = Fnal value y F ° baseline value y 0 positive ¢ y means an increase, negative ¢ y means a decrease. 2

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

View Full Document
Alphabetic List of Variables and Attributes #V a r i a b l e T y p eL e nF o r m a tI n f o r m a tL a b e l 3A g e N u m 8 A g e 9 Base_CRP Num 8 Base CRP 6 Base_Chol Num 8 Base Chol 11 Base_Gluc Num 8 Base Gluc 10 Base_HCYS Num 8 Base HCYS 7B a s e _ H D L N u m 8 B a s e H D L 8B a s e _ L D L N u m 8 B a s e L D L 5B a s e _ T G N u m 8 B a s e T G 22 Final_CRP Num 8 Final CRP 19 Final_Chol Num 8 Final Chol 24 Final_Gluc Num 8 Final Gluc 23 Final_HCYS Num 8 Final HCYS 20 Final_HDL Num 8 Final HDL 21 Final_LDL Num 8 Final LDL 18 Final_TG Num 8 Final TG 1I D N u m 8 I D ... (more) 3 A simple direct approach is to write down all the subtractions: data one; set pubh.barley; dm_chol = Mid_Chol - base_chol; dm: d for delta, m for midpoint dm_TG = Mid_TG - Base_TG; dm_HDL = Mid_HDL - Base_HDL; dm_LDL = Mid_LDL - Base_LDL; dm_CRP = Mid_CRP - Base_CRP; dm_HCYS = Mid_HCYS - Base_HCYS; dm_Ins = Mid_Ins - Base_Ins; dm_Gluc = Mid_Gluc - Base_Gluc; Another block for change from baseline to Fnal value. Use Control-H search and replace. 4
data one; set pubh.barley; dm_chol = Mid_Chol - base_chol; dm_TG = Mid_TG - Base_TG; dm_HDL = Mid_HDL - Base_HDL; dm_LDL = Mid_LDL - Base_LDL; dm_CRP = Mid_CRP - Base_CRP; dm_HCYS = Mid_HCYS - Base_HCYS; dm_Ins = Mid_Ins - Base_Ins; dm_Gluc = Mid_Gluc - Base_Gluc; df_chol = final_Chol - base_chol; df_TG = final_TG - Base_TG; df_HDL = final_HDL - Base_HDL; df_LDL = final_LDL - Base_LDL; df_CRP = final_CRP - Base_CRP; df_HCYS = final_HCYS - Base_HCYS; df_Ins = final_Ins - Base_Ins; df_Gluc = final_Gluc - Base_Gluc; Hard to check. 5 Data step: Arrays ( LSB §3.11) An array is a vector or matrix of variables In a data step, to create a vector array: ARRAY array_name [ number of variables ] variable list ; In a data step, to create a matrix array: ARRAY array_name [ number of rows, number of columns ] list of row 1 variables, row 2 variables, etc ; Whenever you are repeating the same calculation more than twice, consider using arrays.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 14

Handout06 - Lecture 6 1 Repetitive code 2 Arrays 3 Macros 1...

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

View Full Document
Ask a homework question - tutors are online