@K_Wils15
You will get more answers faster if you provide sample data, ask for one thing only per question and provide a desired output.
Here the code for your first homework question.
data VIRUS_PROLIF;
input SAMPLE_NUMBER CELL_TYPE $ COUNT;
datalines;
1 xy 1000
2 xy 80000
3 xy 100000
4 xy 99999
;
data VIRUS_PROLIF2;
set VIRUS_PROLIF;
growth_time=0;
if count<100000 then
do;
do until(COUNT>=100000);
Count+(Count*.01);
growth_time+1;
end;
end;
run;
/**
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.
**/
proc sort data=VIRUS_PROLIF2;
by cell_type;
run;
data VIRUS_PROLIF3(keep=cell_type min_: max_: avg_:);
set VIRUS_PROLIF2;
by cell_type;
retain min_growth_time max_growth_time;
min_growth_time=min(growth_time, min_growth_time);
max_growth_time=max(growth_time, max_growth_time);
_n+1;
_sum_growthtime+growth_time;
if last.cell_type then
do;
avg_growth_time=_sum_growthtime/_n;
output;
call missing(of _:);
end;
run;
proc print;
run;
A Do Until clause always gets executed at least once so even if the cell count is already 100T+ you still would end-up with one iteration and though adding a minute. For this reason I had to add a test first ( if count<100000 then... )
If it was me then I'd go for a DO While and would express the time it takes in seconds so that I can create a SAS Time value (which is the count in seconds). The code could then look like:
data VIRUS_PROLIF2;
set VIRUS_PROLIF;
format growth_time time10.;
do growth_time=0 by 60 while(COUNT<100000);
Count+(Count*.01);
end;
run;
....and hopefully one purpose of this exercise is to demonstrate that sometimes a little bit of math is very useful to speed-up processing and save computer resources.
... View more