M8 Workshop Stat674

data vitals;
   input OBS PATIENT DATE DATE7. PULSE TEMP BPS BPD;
cards;
1 101 25MAY01 72 98.5 130 88
2 101 01JUN01 75 98.6 133 92
3 101 08JUN01 74 98.5 136 90
4 102 30JUL01 81 99.0 141 93
5 102 06AUG01 77 98.7 144 97
6 102 13AUG01 78 98.7 142 93
7 103 24JUL01 77 98.3 137 79
8 103 31JUL01 77 98.5 133 74
9 103 07AUG01 78 98.6 140 80
10 103 14AUG01 75 99.2 147 89
11 104 22AUG01 72 98.8 128 83
12 104 29AUG01 69 98.9 127 82
13 104 05SEP01 71 99.1 131 86
14 104 12SEP01 74 99.0 135 88
;
run;
*Q1(10pts): SELECT vs PROC PRINT;
*Execute the statement below;
*How does the result compare to the result of print statement?;
title ‘first SQL query – data set = vitals’;
proc sql;
   select *
   from vitals;
quit;
proc print data=vitals;
   title ‘proc print – data set =  vitals’;
run;

*Q2(15pts): Use the create table clause to create a table called bp
containing the variables patient, date, BPS and BPD from the
provided data table vitals.;

*Q3(25pts): Create a data table called bp_subset with the following:
*** a. The date variable with a format to look like ‘2020/01/01’;
*** b. The temp variable converted to degrees Celsius;
*** c. Include only records for patients 101 and 103.;
*** d. Resulting table should be sorted by patient id, with last visit date as the first obs for each patient.;
*** e. The created table should contain only variables patient, date, BPS, BPD and temperature in degrees Celsius.;


*Q4(25pts): Create a variable called dosegrp with value “Medication A” for odd numbered patients and “Medication B” for
even numbered patients;
* The result data table should include all the variables from vitals and the created varaible dosegrp;
* Sort the resulting data by patient id;
* Do NOT hard code the patient numbers, this code should work even if additional patients are added to the data set;


*Q5(25pts): Assuming the data is collected from Hypertension patients treated with different medications. We want to see if any patient’s symptoms have improved (BPS dropped below 130) during the treatment process.If so, observe all records of that patient to confirm whether the symptoms are steadily decreasing or if there is any rebound;
* a. Use a WHERE clause to see if there is any patient with BPS below 130. You don’t need to save the result in a data set. Just print it and check the result;
* b. Which patient did you find?Does your result of Q5a show all the records for that patient to observe the trend?
* c. If no, update your PROC SQL to display all the records of the patients whose symptoms have ever shown improvement. Do not manually filter the patients with their ID. The code should work in a large data as well.
      hint: use min() function.

Click here to order similar paper @Udessaywriters.com.100% Original.Written from scratch by professional writers.

You May Also Like

About the Author: admin