Answered step by step
Verified Expert Solution
Question
1 Approved Answer
COMP381 Assignment 5: SAS Deliverables: A PDF le containing properly formatted SAS programs; screenshots of each SAS program in the SAS Studio editor; and screenshots
COMP381 Assignment 5: SAS Deliverables: A PDF le containing properly formatted SAS programs; screenshots of each SAS program in the SAS Studio editor; and screenshots of the input data le contents (where applicable), log, and output windows from the program runs. The late penalty is 10% per day. 1. Use PROC PRINT (without any DATA steps) to create a listing like the one here. Note: The variables in the Hosp data set are Subject, AdmitDate (Admission Date), DischrDate (Discharge Date), and DOB (Date of Birth). The data step that creates this data set can be found in the SAS data sets archive on eCentennial. Hints: ! Variable labels replace variable names. ! ! The number of observations is printed at the bottom of the listing. ! 2. Observations are double-spaced. There are four title lines (the last one being dashes). Let us suppose that you have a large data set containing patient lab results. You also have a small data set containing just patient numbers. You will load the small data set into a hash object using patient numbers as the key. You will then search the hash object to nd key matches between the large and small data sets and output those observations. 2.1. First write the SAS code to create the large data set using this data step * as a reference for deriving your own. The conditions that your large data set must meet are: 2.1.1. The number of unique patients in the data set must be some number between 35,127 and 37,985; and 2.1.2. Each patient has between 0 and 9 ALT lab results (the loop index is a random number in that range); and 2.1.3. The variables that must appear in the large data set are tabled below. Variable Meaning Data Type Conditions (provide a variable name) Unique patient identifying number Number A random number between 32676 and 999999999 ditto The date on which the ALT lab test result was made Number A random date between 1 Jan 2002 and 31 Dec 2007 ditto The ALT lab result value Number A random number between 0 and 300 2.2. Write the code to create the small data set from the large data set using this data step as a reference. Choose a range for the ALT test result date that produces between 14,000 and 17,000 observations in the small data set. 2.3. Write code to retrieve the test results from the large data set for the patients identied in the small data set using the Example 2 sample code from a SAS manual page. Alter the example code in one important way: output only those observations from the large data set with an ALT value >= 275. 2.4. Finally, write code to print the contents of the rst 150 observations retrieved data, grouped by patient identifying number. SAS manual pages describing version 9.4 hash object language elements can be found here: http://support.sas.com/documentation/cdl/en/lecompobjref/67221/HTML/default/ viewer.htm#p0ae2of2fa94xmn1bajgqxczla8u.htm SAS manual pages describing how to use the hash object (with examples) can be found here: http://support.sas.com/documentation/cdl/en/lrcon/68089/HTML/default/ viewer.htm#n1b4cbtmb049xtn1vh9x4waiioz4.htm *Data set HOSP; data learn.hosp; do j = 1 to 1000; AdmitDate = int(ranuni(1234)*1200 + 15500); quarter = intck('qtr','01jan2002'd,AdmitDate); do i = 1 to quarter; if ranuni(0) lt .1 and weekday(AdmitDate) eq 1 then AdmitDate = AdmitDate + 1; if ranuni(0) lt .1 and weekday(AdmitDate) eq 7 then AdmitDate = AdmitDate - int(3*ranuni(0) + 1); DOB = int(25000*Ranuni(0) + '01jan1920'd); DischrDate = AdmitDate + abs(10*rannor(0) + 1); Subject + 1; output; end; end; drop i j; format AdmitDate DOB DischrDate mmddyy10.; run; * *Data set DISCHARGE; data learn.discharge; set learn.hosp(keep=Subject DischrDate rename=(Subject=PatNo) where=(DischrDate between '01Jan2003'd and '31Dec2003'd) firstobs=208 obs=217); run; See SAS manual page http://support.sas.com/documentation/cdl/en/lrcon/68089/HTML/default/ viewer.htm#n1b4cbtmb049xtn1vh9x4waiioz4.htm data match; length k 8; length s 8; if _N_ = 1 then do; /* load SMALL data set into the hash object */ declare hash h(dataset: "work.small"); /* define SMALL data set variable K as key and S as value */ h.defineKey('k'); h.defineData('s'); h.defineDone(); /* avoid uninitialized variable notes */ call missing(k, s); end; /* use the SET statement to iterate over the LARGE data set using */ /* keys in the LARGE data set to match keys in the hash object */ set large; rc = h.find(); if (rc = 0) then output; run
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started