Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Problems

6-1.You have an instream raw data file of patient hospital stays with the following file layout:
Starting
Column    Length   Format       Description
_______________________________________________

   1       3       character    Subject ID
   4       6       mmddyy       Admission date
  10       6       mmddyy       Discharge date
  16       8       mmddyyyy     Date of birth

Here are some sample data:

00101059201079210211946
00211129211159209011955
00305129206099212251899
00401019301079304051952

  1. Write a program to create a SAS data set called DATES1, and list the resulting data set with PROC PRINT. Create variables ID, ADMIT, DISCH, and DOB from the given data, and also create the following new variables:

    AGEage in years on the date of admission (as of the last birthday)
    DAYnumeric day of the week of admission date (1=Sun, 2=Mon, etc.)
    MONTHnumeric month of year of admission date (1=Jan, 2=Feb, etc.)


    Set up the DATA step so that the variables print with the following formats:

    ADMITmm/dd/yy
    DISCHmm/dd/yy
    DOBddMMMyyyy
    AGEno decimals
    DAY3 letter names (SUN, MON, etc.)
    MONTHnumeric (1=Jan, 2=Feb, etc.)


  2. Compute the mean age of all patients (use PROC MEANS — see Chapter 10, “PROC MEANS and PROC UNIVARIATE”).

  3. Create a chart showing the frequency of admissions by day of week (use PROC CHART—see Chapter 12, “PROC CHART”).

  4. Compute frequencies on the number of visits by month of year (use PROC FREQ—see Chapter 10).

6-2.You have a SAS data set, DATES2, that contains variables MONTH and YEAR (of birth), but not day. Create a new data set based on DATES2 and include AGE as of the date the program is run, using the 15th of the month as an approximate day for the date of birth. Round the value of AGE in years to the nearest year. Store the MMDDYY8. format with DOB.
6-3.You have a SAS data set, DATES3, which contains the variables ID, DOB (date of birth), VISIT_D, VISIT_M, and VISIT_Y (visit day, month, and year respectively). Write a program to create a new data set which includes a variable called AGE (approximate age rounded to the nearest year at the time of visit.) Try to calculate the value of AGE with one statement.
6-4.You have a set of raw data showing the number of crayons produced at Company X on certain sample dates. The company started producing crayons in the beginning of 1990.

Here is the raw data file layout:

Starting
Column      Length      Format      Description
______________________________________________________________
   1          8         mm/dd/yy    Date of manufacture
  11          6         numeric     Number of crayons produced

Here are some sample data:

02/01/90  12,500
02/08/90  12,600
04/01/90  13,000
05/05/90  12,800
08/05/90  14,000
12/12/90  14,200
02/18/91  14,400
02/22/91  14,100
05/01/91  15,000

You want to compute the mean number of crayons produced in each quarter, starting from 01/01/90. For example, the mean number of crayons produced in quarter 0 (from 01/01/90 to 03/31/90) is 12,550. There are various ways to do this, but try using the INTCK function. Also, see Chapter 10 for the syntax for PROC MEANS.

6-5.You are assigned the job of “match-making” for a dating firm. The firm has its data in a SAS data set called CLIENTS, consisting of variables ID (ID number), GENDER (M or F), and DOB (date of birth.) The astrologer on staff suggests that there are two compatible groups of clients, one being males born on a Wednesday or Thursday in either January or March, and the other being females born on Fridays in either August or September. First, write a program to create a subset of CLIENTS which contains clients fitting the astrologer’s suggestions. Next, print out two lists, one for females and one for males, listing the clients by ID and showing the DOB, the DAY of the week on which they were born, and the MONTH of the year in which they were born.

Here is part of the CLIENTS data set:

ID    GENDER     DOB
_______________________

18      M      03/07/62
28      F      07/12/67
38      M      03/19/59
53      M      01/25/62
72      F      09/01/67
75      F      08/07/59
77      M      05/17/55
80      F      09/07/62


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint