55 *********************************************; *; 56 * Clinical data set questions: *; 57 * V. Adding Variables and Observations *; 58 *********************************************; 59 60 options linesize=min; 61 62 libname mydir 'c:\My Documents\My SAS Files\sasmanual\data' 62! ; NOTE: Libref MYDIR was successfully assigned as follows: Engine: V7 Physical Name: c:\My Documents\My SAS Files\sasmanual\data 63 data nopreg; 64 set mydir.clinical; 65 if pregnant=0 and gender='F' then output; 66 run; NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column). 65:4 NOTE: There were 34 observations read from the data set MYDIR.CLINICAL. NOTE: The data set WORK.NOPREG has 11 observations and 11 variables. NOTE: DATA statement used (Total process time): real time 0.03 seconds cpu time 0.01 seconds 67 68 proc print data=nopreg; 69 title 'Females that are not pregnant'; 70 run; NOTE: There were 11 observations read from the data set WORK.NOPREG. NOTE: PROCEDURE PRINT used (Total process time): real time 0.01 seconds cpu time 0.01 seconds 71 72 data male; 73 set mydir.clinical; 74 if gender='M' then output; 75 run; NOTE: There were 34 observations read from the data set MYDIR.CLINICAL. NOTE: The data set WORK.MALE has 17 observations and 11 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds 76 77 proc print data=male; 78 title 'Males'; 79 run; NOTE: There were 17 observations read from the data set WORK.MALE. NOTE: PROCEDURE PRINT used (Total process time): real time 0.01 seconds cpu time 0.01 seconds 80 81 data concat; 82 set nopreg (in=m1) 83 male (in=m2); 84 inone=m1; 85 intwo=m2; 86 run; NOTE: There were 11 observations read from the data set WORK.NOPREG. NOTE: There were 17 observations read from the data set WORK.MALE. NOTE: The data set WORK.CONCAT has 28 observations and 13 variables. NOTE: DATA statement used (Total process time): real time 0.04 seconds cpu time 0.01 seconds 87 88 proc print data=concat; 89 format prim_dx sec_dx $dxcodes. 90 dob visit mmddyy8. 91 gender $gender. 92 vitamins pregnant $yesno.; 93 title 'All that are not pregnant concatenated'; 94 run; NOTE: There were 28 observations read from the data set WORK.CONCAT. NOTE: PROCEDURE PRINT used (Total process time): real time 0.06 seconds cpu time 0.03 seconds 95 96 proc sort data=male; 97 by dob; 98 run; NOTE: There were 17 observations read from the data set WORK.MALE. NOTE: The data set WORK.MALE has 17 observations and 11 variables. NOTE: PROCEDURE SORT used (Total process time): real time 0.10 seconds cpu time 0.03 seconds 99 100 proc sort data=nopreg; 101 by dob; 102 run; NOTE: There were 11 observations read from the data set WORK.NOPREG. NOTE: The data set WORK.NOPREG has 11 observations and 11 variables. NOTE: PROCEDURE SORT used (Total process time): real time 0.01 seconds cpu time 0.01 seconds 103 104 data interleave; 105 set nopreg 106 male; 107 by dob; 108 run; NOTE: There were 11 observations read from the data set WORK.NOPREG. NOTE: There were 17 observations read from the data set WORK.MALE. NOTE: The data set WORK.INTERLEAVE has 28 observations and 11 variables. NOTE: DATA statement used (Total process time): real time 0.03 seconds cpu time 0.03 seconds 109 110 proc print data=interleave; 111 format prim_dx sec_dx $dxcodes. 112 dob visit mmddyy8. 113 gender $gender. 114 vitamins pregnant $yesno.; 115 title 'All that are not pregnant interleaved by dob'; 116 run; NOTE: There were 28 observations read from the data set WORK.INTERLEAVE. NOTE: PROCEDURE PRINT used (Total process time): real time 0.06 seconds cpu time 0.03 seconds 117 title; 118 119 data one; 120 set mydir.clinical (keep=id gender dob prim_dx sec_dx); 121 run; NOTE: There were 34 observations read from the data set MYDIR.CLINICAL. NOTE: The data set WORK.ONE has 34 observations and 5 variables. NOTE: DATA statement used (Total process time): real time 0.03 seconds cpu time 0.01 seconds 122 123 data two; 124 set mydir.clinical (keep=gender hr); 125 run; NOTE: There were 34 observations read from the data set MYDIR.CLINICAL. NOTE: The data set WORK.TWO has 34 observations and 2 variables. NOTE: DATA statement used (Total process time): real time 0.03 seconds cpu time 0.01 seconds 126 127 proc print data=one; 128 title 'Data=One'; 129 run; NOTE: There were 34 observations read from the data set WORK.ONE. NOTE: PROCEDURE PRINT used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 130 131 proc print data=two; 132 title 'Data=Two'; 133 run; NOTE: There were 34 observations read from the data set WORK.TWO. NOTE: PROCEDURE PRINT used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 134 135 proc sort data=one; 136 by gender; 137 run; NOTE: There were 34 observations read from the data set WORK.ONE. NOTE: The data set WORK.ONE has 34 observations and 5 variables. NOTE: PROCEDURE SORT used (Total process time): real time 0.03 seconds cpu time 0.03 seconds 138 139 proc sort data=two; 140 by gender; 141 run; NOTE: There were 34 observations read from the data set WORK.TWO. NOTE: The data set WORK.TWO has 34 observations and 2 variables. NOTE: PROCEDURE SORT used (Total process time): real time 0.01 seconds cpu time 0.01 seconds 142 143 data mer; 144 merge one (in=m1) 145 two (in=m2); 146 inone=m1; 147 intwo=m2; 148 run; NOTE: There were 34 observations read from the data set WORK.ONE. NOTE: There were 34 observations read from the data set WORK.TWO. NOTE: The data set WORK.MER has 34 observations and 8 variables. NOTE: DATA statement used (Total process time): real time 0.03 seconds cpu time 0.03 seconds 149 150 proc print data=mer; 151 title 'Adding hr variable using Merge'; 152 run; NOTE: There were 34 observations read from the data set WORK.MER. NOTE: PROCEDURE PRINT used (Total process time): real time 0.01 seconds cpu time 0.01 seconds 153 154 data mer; 155 merge one (in=m1) 156 two (in=m2); 157 by gender; 158 if hr>70 then output; 159 run; NOTE: MERGE statement has more than one data set with repeats of BY values. NOTE: There were 34 observations read from the data set WORK.ONE. NOTE: There were 34 observations read from the data set WORK.TWO. NOTE: The data set WORK.MER has 24 observations and 6 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds 160 161 proc print data=mer; 162 title 'All patients with heart rate over 70'; 163 run; NOTE: There were 24 observations read from the data set WORK.MER. NOTE: PROCEDURE PRINT used (Total process time): real time 0.04 seconds cpu time 0.00 seconds 164 165 proc means data=mydir.clinical noprint nway; 166 class gender; 167 var hr; 168 output out=mhr mean=mean_hr; 169 run; NOTE: There were 34 observations read from the data set MYDIR.CLINICAL. NOTE: The data set WORK.MHR has 2 observations and 4 variables. NOTE: PROCEDURE MEANS used (Total process time): real time 0.15 seconds cpu time 0.01 seconds 170 171 proc print data=mhr; 172 title 'Mean heart rate by gender'; 173 run; NOTE: There were 2 observations read from the data set WORK.MHR. NOTE: PROCEDURE PRINT used (Total process time): real time 0.01 seconds cpu time 0.01 seconds 174 175 proc sort data=mydir.clinical out=clin; 176 by gender; 177 run; NOTE: There were 34 observations read from the data set MYDIR.CLINICAL. NOTE: The data set WORK.CLIN has 34 observations and 11 variables. NOTE: PROCEDURE SORT used (Total process time): real time 0.03 seconds cpu time 0.03 seconds 178 179 proc sort data=mhr; 180 by gender; 181 run; NOTE: There were 2 observations read from the data set WORK.MHR. NOTE: The data set WORK.MHR has 2 observations and 4 variables. NOTE: PROCEDURE SORT used (Total process time): real time 0.01 seconds cpu time 0.01 seconds 182 183 data mer; 184 merge clin (in=m1) 185 mhr (in=m2); 186 by gender; 187 if hr>mean_hr then hi_hr=1; 188 else hi_hr=0; 189 label hi_hr='Heart Rate Greater than the Mean value for each sex'; 190 run; NOTE: There were 34 observations read from the data set WORK.CLIN. NOTE: There were 2 observations read from the data set WORK.MHR. NOTE: The data set WORK.MER has 34 observations and 15 variables. NOTE: DATA statement used (Total process time): real time 0.04 seconds cpu time 0.04 seconds 191 192 proc print data=mer; 193 title 'Data mer - adding mean heart rate by gender'; 194 run; NOTE: There were 34 observations read from the data set WORK.MER. NOTE: PROCEDURE PRINT used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 195 196 proc means data=mer n sum mean; 197 title 'Proportion of observation with Heart rate greater than the mean heart rate'; 198 class gender; 199 var hi_hr; 200 run; NOTE: There were 34 observations read from the data set WORK.MER. NOTE: PROCEDURE MEANS used (Total process time): real time 0.06 seconds cpu time 0.01 seconds