I have been working on this homework assignment all day and still have three questions I just cannot solve:
1) There is a data file called VIRUS_PROLIF. Three variables: SAMPLE_NUMBER CELL_TYPE, and COUNT. COUNT is a value for the initial count of the number of virions in a cell. If we assume that the virions replicate at a rate such that the total number of virions will increase by 10% per minute, write the SAS code using DO UNTIL to calculate how long one would predict it would take (in minutes) for the number of virions to exceed 100,000 for each cell.
Then, write the SAS code using a data step and accumulating variables to calculate the minimum, maximum, and average time to exceed 100,000 virions for the cells of each CELL_TYPE.
Here is what I have for that one:
data VIRUS_PROLIF2;
set VIRUS_PROLIF;
do until(COUNT>100000);
Count+(Count*.01);
end;
run;
proc sort data=VIRUS_PROLIF2 out=VIRUS_PROLIF3;
by SAMPLE_NUMBER CELL_TYPE COUNT;
run;
data CELL_TYPE_DATA (keep = SAMPLE_NUMBER CELL_TYPE COUNT n_cell_type min_cell_type max_Cell_type
avg_cell_type sum_Cell_type);
set Virus_Prolif3;
by SAMPLE_NUMBER CELL_TYPE COUNT;
retain min_cell_type max_Cell_type sum_Cell_Type n_Cell_type;
if first.Cell_Type then do;
min_Cell_type = Cell_Type;
max_Cell_Type = Cell_Type;
sum_Cell_Type = 0;
n_Cell_TYPE = 0;
end;
sum_Cell_TYPE = sum(sum_Cell_TYPE, Cell_TYPE);
n_CELL_TYPE = sum(n_CELL_TYPE, 1);
min_CELL_TYPE = min(min_CELL_TYPE, CELL_TYPE);
max_CELL_TYPE = max(max_Cell_TYPE, CELL_TYPE);
avg_CELL_TYPE = sum_CELL_TYPE / n_CELL_TYPE;
if last.CELL_TYPE;
run;
2. There is data set 'HW3_Items' contains the students' answers to a 25-question test (variables = answer_01 to answer_25). On each student's observation, we also have variables for the correct answers (variables = correct_01 to correct_25). Write a data step in which you will use arrays and a DO loop to determine each student's score on the test (1 point for each correct answer).
Here is what I have for that:
data HW3_ITEMS2;
Set HW3_ITEMS;
array Answer {25} answer_01 - answer_25;
array Correct_Answer {25} correct_01 - correct_25;
array Answer_Correct {25} Answer_correct_01 - Answer_correct_25;
do x = 1 to 25;
if Answer[X] - Correct_Answer[X] = 0 then Answer_Correct[X] = 1 + x ;
else Answer_Correct[X] = 0;
end;
run;
proc print data=HW3_ITEMS2;
run;
3. Last one is looking at overweight and normal weight individuals using data set sashelp.heart and I write the SAS code to test whether the mean cholesterol level for normal weight subjects differed significantly from that of overweight subjects. I know that it is a ttest. But every time I try to do proc ttest
data=sashelp.heart;
class Weight_Status;
var Chol_STATUS;
run;
There is an error and I am not sure why or how to fix it.
Please advise! Any advice would be greatly appreciated.