{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Chapter7

Chapter7 - Chapter 7 Chapter 7 7.1 SAS General functions...

This preview shows pages 1–5. Sign up to view the full content.

Chapter 7 SAS - 1 - Chapter 7 General functions and SAS Macros 7.1 General functions 1. Time and date a. The TIME function finds the time written as one number (may not make sense by itself). b. The HOUR, MINUTE, and SECOND functions pull their corresponding values out of the TIME() value. c. The TODAY function finds the number of days since January 1, 1960. d. The MONTH, DAY, and YEAR functions pull their corresponding values out of the TODAY() value. e. SAS Code and output are: *Find the date and time; data time; time_func = time(); hour = hour(time()); minute = minute(time()); second = second(time()); month = month(today()); day = day(today()); year = year(today()); run ; title2 'The time is:' ; proc print data =time; run ; 2. Summary functions a. Max and sum (many others are available) b. Notice the use of “OF” in the code. c. SAS Codes and output are given next: data set1; input x1 x2 x3; datalines ; 1 2 3 4 5 6 ; run ;

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Chapter 7 SAS - 2 - data set2; set set1; sum1 = sum(x1, x2, x3); sum2 = sum(of x1-x3); max1 = max(x1, x2, x3); max2 = max(of x1-x3); run ; title2 'Illustrate the sum and max functions' ; proc print data =set2; run ; Illustrate the sum and max functions Obs x1 x2 x3 sum1 sum2 max1 max2 1 1 2 3 6 6 3 3 2 4 5 6 15 15 6 6 3. Percentiles (or quantiles) of probability distributions a. Some of the distributions we will consider are: Standard normal, t, F, and χ 2 b. We want to obtain the area to the left of the percentile c. Example: Let Z be a standard normal random variable. Then P(Z>1.96)=0.025 and P(Z<1.96)=0.975. Given below are some codes and output illustrating how to find percentiles (or quantiles ). i. Notice (1-alpha) is used in the call to the functions since alpha is usually used to denote the area to the RIGHT of the percentile of interest. data set3; input alpha df1 df2; norm = probit( 1 -alpha); t = tinv( 1 -alpha, df1); chisq = cinv( 1 -alpha, df1); f = finv( 1 -alpha, df1, df2); datalines ; 0.01 5 5 0.025 5 5 0.05 5 5 0.10 5 5 ; run ; title2 'Percentiles from probability distributions' ; proc print data =set3; run ;
Chapter 7 SAS - 3 - Percentiles from probability distributions Obs alpha df1 df2 norm t chisq f 1 0.010 5 5 2.32635 3.36493 15.0863 10.9670 2 0.025 5 5 1.95996 2.57058 12.8325 7.1464 3 0.050 5 5 1.64485 2.01505 11.0705 5.0503 4 0.100 5 5 1.28155 1.47588 9.2364 3.4530 Let Z be a standard normal random variable. Then P(Z<2.32635) = 0.99 and P(Z>2.32635) = 0.01. Let t be a random variable from a t-distribution with 5 degrees of freedom. Then P(t<3.36493) = 0.99 and P(t>3.36493) = 0.01. Let X be a random variable from a χ 2 distribution with 5 degrees of freedom. P(X<15.0863) = 0.99 and P(X>15.0863) = 0.01. Let F be a random variable from an F-distribution with 5 numerator and 5 denominator degrees of freedom. P(F<10.9670) = 0.99 and P(F>10.9670) = 0.01 d. What would the percentiles be if instead of (1-alpha), you just used alpha? Find on your own! i. Normal: ii. T: iii. Chi-square: iv. F: *Another example; data set4; input area_to_left; norm = probit(area_to_left); datalines ; 0.975 0.025 ; run ; proc print data =set4; run ; Percentiles from probability distributions area_to_ Obs left norm 1 0.975 1.95996 2 0.025 -1.95996

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document