BookmarkSubscribeRSS Feed
ChuksManuel
Pyrite | Level 9

Dear programmers,

 

Please i need help to do 2 questions. I'm  practicing for the Base SAS exams and i could not write the codes for these questions.

Any help or answer will be appreciated. 

 

  1. Assume you have a SAS data set called INF_TEMPS from an infectious disease research center. Each observation has the variable SUBJ_ID and 25 values (named FTEMP_01 – FTEMP_25) for the subject’s body temperature which were measured hourly over a one day period. The values in the data set are given in degrees Fahrenheit and we need to convert these values to degrees Celcius.  The formula for conversion is (F – 32) * 5 / 9 = C.  Set up an array for the original temperature values and an array for the new values.  Then use a DO LOOP to make the conversion. 

 

2. Assume you have a data file called VIRUS_PROLIF from an infectious disease research center. Each observation has 3 variables SAMPLE_NUMBER CELL_TYPE, and COUNT, where 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.

 

 

 

5 REPLIES 5
ChuksManuel
Pyrite | Level 9

Thanks. I am learning both because my work need me to know them also.

Any help is appreciated.

ChuksManuel
Pyrite | Level 9

Dear programmers,

 

Please i need help to do 2 questions on a SAS practice. Any help or answer will be appreciated.  The questions and the codes that i wrote are attached. 

 

  1. Assume you have a SAS data set called INF_TEMPS from an infectious disease research center. Each observation has the variable SUBJ_ID and 25 values (named FTEMP_01 – FTEMP_25) for the subject’s body temperature which were measured hourly over a one day period. The values in the data set are given in degrees Fahrenheit and we need to convert these values to degrees Celcius.  The formula for conversion is (F – 32) * 5 / 9 = C.  Set up an array for the original temperature values and an array for the new values.  Then use a DO LOOP to make the conversion. 

 

data NewPatientTemp (drop=i);

set Inf_Temps;

 

/*Code to declare arrays*/

array FTemp{25} FTemp_01-FTemp_25;

array Temps_New{25} Temps_New1-Temps_New25;

 

/*Do loop to convert Fahrenheit temps to  Celsuis*/

do i=1 to 25;

Temps_New(i)= 5/9* (Temps (i) - 32);

end;

run;

 

2. Assume you have a data file called VIRUS_PROLIF from an infectious disease research center. Each observation has 3 variables SAMPLE_NUMBER CELL_TYPE, and COUNT, where 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.

 

 data Virus_prolif;
do until (count>100000);
minute+1;
count+ (counts*0.1);
end;
run;
proc print data=Virus_Prolif noobs;
run;

 

Please I need code critique and how i can make it better. 

ballardw
Super User

 data Virus_prolif;
do until (count>100000);
minute+1;
count+ (counts*0.1);  <= since count is undefine AND Counts is undefined then missing + missing is missing and you never reach any value so the loop never stops. Make sure the loop counter variable is the same in both places and there is a non-zero value set somewhere prior to the DO UNTIL statement using the variable.
end;
run;

Tom
Super User Tom
Super User

Show what you have tried and either show the errors or explain why it doesn't do what you want.

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1731 views
  • 0 likes
  • 4 in conversation