HW 3 SAS Code for Problems 3-5 and EC

txt

School

University Of Arizona *

*We aren’t endorsed by this school

Course

387

Subject

Industrial Engineering

Date

Dec 6, 2023

Type

txt

Pages

3

Uploaded by CaptainApe3549

Report
/* BIOS 576D Course Homework Problem #3: The Glomerular Filtration Rate (GFR) */ /* Question #3 (4 points): For each patient, compute eGFR by using the MDRD formula provided. Some patients have missing data, so assume "complete case" analysis is apppropriate. Provide a printout of your results for the first 35 patients. Calculate and interpret appropriate descriptive statistics for eGFR. Submit your results using LISTING (i.e., text) output */ /* Approach: Calculate eGFR for patients with non-missing CR_M1 values. Use PROC MEANS to generate descriptive statistics for continuous variable eGFR */ data work.test_sample_3gfr; set work.test_sample_3; format eGRF 5.1; if r_race in('AmIndian', 'Caucasia', 'Other') then race=1; /* create new race var */ else if r_race = 'AfrAmeri' then race=1.212; if r_gender = 'M' then sex=1; else if r_gender = 'F' then sex=0.742; /* create new gender var */ eGRF=175*(CR_1M**(-1.154))*(r_age**(-0.203))*race*sex; run; *ods listing; /*This syntax only works in SAS Windowing Environment & Enterprise Guide*/ ods listing file='~/bios576d/eGRF.lst'; /* Required syntax for SAS Studio. Extension .txt also works */ title 'Question #3: Calculated Patient eGFR (First 35 observations)'; proc print data=work.test_sample_3gfr (obs=35); run; title 'Question #3: Descriptive Statistics for eGFR'; proc means data=work.test_sample_3gfr; var eGRF; run; title; ods listing close; /* The above ODS code creates text file eGRF.lst and places it in the bios576d directory. Double-clicking it opens it in an output tab within SAS Studio */ /* Question #4 (3 points): Using the Stages of Chronic Kidney Disease (CKD) table provided, classify the patients' calculated kidney function according to the appropriate CKD stage. Provide a printout of your results for the first 35 patients. Is there a problem with classifying some of the patients' eGFR levels? If yes, please describe it. Submit your results using PDF output */ /* Approach: Assign an appropriate CKD Stage number to each patient based on their eGFR, accounting for eGFR values that are above 100 (above CKD Stage 1) */
data work.test_sample_3stages; set work.test_sample_3gfr; if eGRF ge 0 and eGRF lt 15 then CKD_Stage = 5; else if eGRF ge 15 and eGRF le 29 then CKD_Stage = 4; else if eGRF ge 30 and eGRF le 59 then CKD_Stage = 3; else if eGRF ge 60 and eGRF le 89 then CKD_Stage = 2; else if eGRF ge 90 and eGRF le 100 then CKD_Stage = 1; /* Assign a missing value for Stage if eGRF > 100 (outside the criteria table limits) */ else if eGRF gt 100 then CKD_Stage = .; else CKD_Stage = .; run; ods pdf file='~/bios576d/CKD_table.pdf'; /* No alternate syntax available */ title 'Question #4: Calculated Patient eGRF Classified by Stages'; proc print data=work.test_sample_3stages (obs=35); run; ods pdf close; /* The above ODS code creates PDF file CKD_table.pdf and places it in the bios576d directory. Double-clicking it downloads it, where it can be opened using Adobe Acrobat */ /* Problem: Some of the patients' eGRFs fall outside the stages defined in the CKD table, either from being >100 or from being non-integer values falling into gaps built into the table. This suggests improper table design */ /* Question #5 (1 point): Using PROC FREQ provide a simple frequency count for the patients that are in each CKD stage. Be sure your PROC step counts the number of patients with missing data. Submit your results using the output type of your choice */ /* Default back to HTML to print the results of PROC FREQ in the SAS Studio RESULTS tab. Note: If output type of choice is HTML, using the SAS Output Delivery System (ODS) to generate an HTML output file is optional */ ods html path= '~/bios576d/' body= 'CKD_stages.html'; /* Note: Can use file=option instead of body=option */ title 'Question #5: CKD Stage Frequency Count'; proc freq data=work.test_sample_3stages; tables CKD_Stage / missing; run; title; ods html close; /* Note: For the 307 patients listed in input SAS data set test_sample_3, 12 had missing eGRFs because of missing values in variable CR_1M (eGRF=. due to complete case analysis assumption) 9 had eGRF values that fell into Stage 1-5 range definitions gaps 4 had eGRF values greater than 100 (above the top of the Stage 1 range
=> calculated in the Optional Extra Credit problem below) ------------------------------------------------------------------------- 25 total patients could not be assigned to a CKD_Stage => CKD_Stage=. */ /* OPTIONAL: Extra credit (1 point) Calculate how many of the patients with missing CKD stage values in problem (5) had an eGFR greater than 100. a. Use a DATA _null_ step containing a “sum statement” to perform the calculation. b. Use PUTLOG in the DATA _null_ step to output the result to the SAS Log for the last observation in the data set (end of file). Information in TLSB 3.15, 4.9, 11.9, the course notes, and from on-line research on the topic of “SAS End-of-File Processing” should be helpful. Hint: Adapt the code shown at https://online.stat.psu.edu/stat481/lesson/13/13.4 for use in a DATA _null_ step (ignore the PROC PRINT step code) */ data _null_; set work.test_sample_3stages end=LAST; /* Note: Initially, LAST=0. At end of file (EOF), the value of LAST is changed from 0 to 1 */ if eGRF gt 100 then eGRF_GT_100+1; /* sum statement */ if LAST=1 then putlog eGRf_GT_100=; if LAST then putlog 'Count eGFR>100= ' eGRf_GT_100; /* alternative code */ run; /* Answer - The following results are written to the SAS Log: eGRF_GT_100=4 Count eGFR>100= 4 */
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help