Code - Homework 29.sas
Code - Homework 29.sas
sas
/* Question 1 */
data cholesterol;
infile '/home/u64124859/cody_chap07_num02-1.dat';
input value1-value10;
array values{10} value1-value10;
do i = 1 to 10;
value = values{i};
if i <= 10 then treatment = 'Statin1';
else if i <= 20 then treatment = 'Statin2';
else treatment = 'Placebo';
output;
end;
drop value1-value10 i;
run;
/* Question 2 */
data depression;
array scores[2,2,4] _temporary_ (
9 11 10 10, 9 6 6 7,
5 4 7 7, 12 11 10 11
);
do group = 1 to 2;
do trt = 1 to 2;
do rep = 1 to 4;
score = scores[group, trt, rep];
if group = 1 then group_label = 'Deficiency';
else if group = 2 then group_label = 'Normal';
output;
end;
end;
end;
run;
/* Question 3 */
DATA co_vary;
DO I = 1 TO 20;
DO GROUP = 'A','B';
SUBJ + 1;
IQ = INT(RANNOR(124)*10 + 120 + 15*(GROUP EQ 'A'));
SCORE = INT(.7*IQ + RANNOR(0)*10 + 100 + 10*(GROUP EQ 'B'));
OUTPUT;
END;
END;
DROP I;
RUN;
about:blank 3/3