67% found this document useful (3 votes)
705 views240 pages

Stock Market Analysis Using SAS PDF

Uploaded by

NikhilKapoor29
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
67% found this document useful (3 votes)
705 views240 pages

Stock Market Analysis Using SAS PDF

Uploaded by

NikhilKapoor29
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 240
f \/ Stock Market Analysis Using /the SAS System: Portfolio Selection and Evaluation GSAS. | vena ~ Stock Market Analysis Using the SAS’ System: Portfolio Selection and Evaluation Version 6 First Edition I SAS Institute Inc. SAS Campus Drive Cary, NC 27513 Contents Chapter 1- Background Topics 1 Introduction 1 Single-Period Return Measure 3 Multiple-Period Return Measures 9 Calculating Expected Returns 14 Risk Measures 19 Learning More 22 References 22 Chapter 2- Discounted Cash Flow (DCF) Analysis 23 Introduction 23 Fixed-Dollar Dividends 24 Constant-Growth Dividends 26 Multiperiod DCF Methodology 42 Searching For Overpriced and Underpriced Stocks 51 Chapter Summary 57 Learning More 57 References 57 Chapter 3- Sorting and Clustering Stocks 59 Introduction 59 Sorting Stocks by Financial Characteristics 60 Clustering Stocks by Financial Characteristics 62 Creating Tree Diagrams 80 Learning More 88 References 88 Chapter 4. The Capital Asset Pricing Model (CAPM) 91 Introduction 91 The CAPM in Risk Premium Form 92 Applying the CAPM to Additional Stocks 108 Using the CAPM fis and the Security Market Line 121 Chapter Summary 126 Learning More 127 References 127 iv Contents Chapter 5 - Portfolio Creation with Linear Programming 129 Introduction 129 Portfolio Creation Using Linear Programming 130 Portfolio Creation Using Integer Programming 145 Portfolio Creation with Short Sales Allowed 151 Chapter Summary 158 Learning More 158 References 159 Chapter 6 - The Markowitz Model, Portfolio Creation with Nonlinear Programming 161 Introduction 161 Portfolio Creation Using the DATA step and PROC CORR 162 Portfolio Creation Using PROC NLP 172 Chapter Summary 195 Learning More 195 References 195 Chapter 7 - Evaluating Portfolios 197 Introduction 197 Comparing Expected and Actual Returns 198 Evaluating Portfolio Performance Using CAPM Regressions 211 Evaluating Portfolio Performance Using Total Risk 214 Learning More 215 References 216 Chapter 8- Valuing Stock Options 217 Introduction 217 Valuing Options Using the Binomial Method 219 Valuing Options Using the Black-Scholes Method 227 Learning More 230 References 230 Glossary 231 Index 235 Credits Design and Production Style Programming Technical Review Writing and Editing Design, Production, and Printing Services Publications Technology Development James J. Ashton, Darius S. Baer, John C. Brocklebank, Brent L. Cohen, Mark W. Craver, Anwar El-Jawhari, Benno Kurch, Tae Yoon Lee, W. Lee Richardson, Mike Stockstill N. Elizabeth Malcom, Susan H. McCoy, Patsy J. Poole, Josephine P. Pope, James D. Seabolt, Joan M. Stout vii Using This Book Purpose Stock Market Analysis Using the SAS System: Portfolio Selection and Evaluation provides a set of example analyses using SAS software to analyze the return and risk of stocks, singly and in portfolios. This book is a task-oriented applications guide that shows how to use the SAS System to analyze risk and return of stocks, create and maintain portfolios, and value stock options. The guide explains how to use features of base SAS software, the REG and CLUSTER procedures from SAS/STAT software, and the LP procedure from SAS/OR software for stock market analysis. Several theoretical approaches are presented: Discounted Cash Flow (DCF) Analysis, the Capital Asset Pricing Model (CAPM), Linear Programming Models, and the Markowitz Model. This book does not include technical analysis, which will be presented in a second volume of techniques for stock market analysis. “Using This Book” contains important information to assist you as you read this book. This information describes the intended audience, prerequisites, and the book’s organization and conventions. “Using This Book” also has an “Additional Documentation” section that provides references to other books containing information on related topics. Audience Stock Market Analysis Using the SAS System: Portfolio Selection and Evaluation is intended for those with interest in analyzing the risk and return of stocks, including finance professionals and the interested nonspecialist, as well as university students at the master’s level and upper-level undergraduates. Minimal knowledge of computing, statistics, and mathematical programming is required to work through the examples. Knowledge of finance at the level of Modern Portfolio Theory and Investment Analysis, by Elton and Gruber, is suggested but not required. Prerequisites Little or no experience with the SAS System is required to use Stock Market Analysis Using the SAS System: Portfolio Selection and Evaluation. The following table summarizes the SAS System concepts you need to use this book: You need to know howto... Refer to... invoke the SAS System at instructions provided by the SAS Software Consultant your site at your site. have a basic understanding of SAS Language and Procedures: Introduction, Version SAS System concepts, suchas _6, First Edition for a brief introduction, or SAS the DATA step Language and Procedures: Usage, Version 6, First Edition and SAS Language and Procedures, Usage 2, Version 6, First Edition for a more thorough introduction. Readers of Stock Market Analysis Using the SAS System: Portfolio Selection and Evaluation are assumed to be familiar with the computer platform they use, but no formal computing background or graduate level statistical training is assumed. Readers are assumed to be familiar with basic statistical concepts of mean and variance, and have been exposed to regression analysis and hypothesis testing at an introductory level. What You Should Read The following table lists some of the stock market analysis tasks you may want to perform and the appropriate chapters to read to accomplish those tasks: If you want to ... Read... calculate risk and return Chapter 1, “Background Topics” and measures Chapter 7, “Evaluating Portfolios” value stocks Chapter 2, “Discounted Cash Flow (DCF) Analysis” sort and cluster stocks Chapter 3, “Sorting and Clustering Stocks” perform Capital Asset Chapter 4, “The Capital Asset Pricing Pricing Model analysis of Model (CAPM)” stocks. calculate portfolio weights Chapter 5 “Portfolio Creation with Linear Programming” and Chapter 6, “The Markowitz Model, Portfolio Creation with Nonlinear Programming” evaluate portfolio Chapter 7, “Evaluating Portfolios” performance value stock options Chapter 8, “Valuing Stock Options” Conventions This section explains the various conventions used to present text and examples in this book. Typographical Conventions Stock Market Analysis Using the SAS System: Portfolio Selection and Evaluation uses several type styles for presenting information. The following list explains the meaning of the typographical conventions used in this book. roman is the standard type style used for most text in this book. UPPERCASE ROMAN is used for SAS language elements. Using This Book ix bold is used for headings, matrices, and vectors. bold italics is used for italicized words when they appear in headings. italic is used for terms that are defined in text, for emphasis, for user-supplied values (in text or syntax), and for references to publications. code is used to show example code and SAS System messages that are set off from the text. In most cases, this book uses lowercase type for SAS code, with the exception of some title characters. SAS System messages appear in mixed case. Example Conventions Most examples in Stock Market Analysis Using the SAS System: Portfolio Selection and Evaluation build upon previous examples. Except where it would be redundant, each example contains O anexplanation of the nature of the example OQ anexplanation of the SAS statements and options 0 the SAS program for you to submit during your interactive SAS session © asample of the output you should see on your display © adescription or an interpretation of the results. Feedback If you have comments or suggestions about this book, any other SAS software manual, or the software, we would like to hear from you. You may write us at the Institute or contact us by using one of our electronic mail addresses. Refer to the Your Turn page at the end of this book for information on how to forward your comments to the appropriate division. Additional Documentation SAS Institute provides many publications about products of the SAS System and how to use them on specific hosts. For a complete list of SAS publications, you should refer to the current Publications Catalog. The catalog is produced twice a year. You can order a free copy of the catalog by writing, calling, or faxing the Institute: SAS Institute Inc. Book Sales Department SAS Campus Drive Cary, NC 27513 Telephone: 919-677-8000 Fax: 919-677-8166 x Using This Book SAS Software Documentation In addition to Stock Market Analysis Using the SAS System: Portfolio Selection and Evaluation , you will find these other documents helpful when using SAS/STAT and SAS/OR software for stock market analysis: SAS/STAT User’ s Guide, Version 6, Fourth Edition, Volume 1 and Volume 2 (order #A56045) documents all procedures in Release 6.06 SAS/STAT software. a SAS/OR User’ s Guide, Version 6, First Edition (order #45850) documents all procedures in Release 6.06 SAS/OR software. Documentation for Other SAS Software Products The SAS System includes many software products in addition to SAS/STAT software and SAS/OR software. Several books about other software products that may be of particular interest to you are listed here: 0 SAS Language and Procedures: Introduction, Version 6, First Edition (order #456074) gets you started if you are unfamiliar with the SAS System. SAS Language and Procedures: Usage, Version 6, First Edition (order #456075) provides task-oriented examples of the major features of base SAS software. OQ SAS Language and Procedures: Usage 2, Version 6, First Edition (order #A56078) provides additional task-oriented examples of the major features of base SAS software. a SAS Language: Reference, Version 6, First Edition (order #456076) provides detailed reference information about all elements of base SAS software except procedures. SAS Procedures Guide, Version 6, Third Edition (order #456080) provides detailed reference information about the procedures in base SAS software. wt Chapter 1 Introduction Background Topics Introduction 1 Hardcopy Data Sets 2 Electronically Stored Data Sets 3 Single-Period Return Measure 3 Introducing the SP] Data Set 4 Plotting the SP] DataSet 6 Calculating Single-Period Returns 7 Plotting Returns 8 Multiple-Period Return Measures 9 Calculating Multiple-Period Return Measures 10 Subsetting a Data Set 10 Transposing a Data Set 11 Calculating Return Measures 12 Calculating Expected Returns 14 Calculating Mean Return Values 14 Calculating the Mean of a Discrete Distribution 15 Using a Growth Rate to Calculate Expected Returns 17 Risk Measures 19 Calculating Risk from Historical Data 19 Calculating Risk from Discrete Distribution 20 Learning More 22 References 22 This chapter introduces basic concepts of stock market analysis and discusses stock markets, stock market data, and measures of risk and return. Typically, the process of stock market analysis follows these general steps: 1. collecting data creating a SAS data set containing your data calculating measures of stock return and risk sorting and clustering stocks by desired financial characteristics assessing the stock’s performance in relation to the market portfolio and to other stocks calculating solution values for portfolio weights deciding in which portfolio to invest ena Yh fF YN evaluating the performance of your portfolio. This chapter shows you how to use the SAS System to perform the first three steps of this analysis. Other chapters discuss the remaining steps. 2 Introduction a Chapter 1 Hardcopy Data Sets You can collect stock data and financial information and then create data sets from any source of financial data, including newspapers and magazines, corporate reports, brokerage firm research reports, investment services reports and newsletters, and government publications. Depending on the intended purpose for your analysis, you may want to create time-series data sets (consisting of observations on a single stock across time), cross-sectional data sets (consisting of observations at one point in time across many stocks), and time-series cross-sectional data sets, also known as panel data sets (consisting of observations on multiple stocks across time). A typical financial page of a major newspaper contains a variety of financial information, including © quotations for stocks, stock options, and mutual funds 2 bond yields 0 yields of U.S. Treasury Securities © interest rates OG exchange rates. Stocks are listed on a variety of exchanges. The exchange on which a stock or mutual fund is listed depends on the dollar value of the firm, its history of earnings, and the number of shares held publicly as well as their market value. The largest firms (in terms of dollar value) are listed on the New York Stock Exchange (NYSE); medium-sized firms are listed on the American Stock Exchange (AMEX); and small firms traded over-the-counter (OTC) are listed by the National Association of Securities Dealers Automated Quotations (NASDAQ). Transactions are regulated by the Securities and Exchange Commission (SEC). Stock and mutual fund quotations listed in the financial pages of major newspapers often have the following form: Stock High Low Close Change XYZ 50 1/8 48 49 1/2 45/8 The quotation is interpreted as follows: XYZ is the exchange abbreviation for the XYZ company. 50 1/8 is the daily high price for stock of firm XYZ. 48 is the daily low price for stock of firm XYZ. 49 1/2 is the daily closing price for stock of firm XYZ. +5/8 indicates that the stock of firm XYZ closed +5/8 higher today than the previous trading day. Some newspapers and daily journals also list additional information, including the number of shares traded (volume), the 52-week high and low, and the rankings based on earnings per share, relative price volatility measures, and relative price-earnings measures. Data sets in hardcopy form can be typed into or electronically scanned into SAS data sets. Background Topics © Single-Period ReturnMeasure 3 Electronically Stored Data Sets Data sets created by a variety of software products can be converted to SAS data sets in a SAS DATA step. For examples and discussion, see SAS Language and Procedures, Usage, Version 6, First Edition and SAS Language and Procedures, Usage 2, Version 6, First Edition. Economic and financial data files can be read and stored as SAS data sets by the SAS/ETS CITIBASE and DATASOURCE procedures. Data files supported by PROC DATASOURCE include co U.S. Bureau of Economic Analysis data files 1 U.S. Bureau of Labor Statistics data files 4 Standard & Poor’s Compustat Services Financial Database Files FAME Software Corporation's CITIBASE data files (tape format, old format, and PC diskette format) Center for Research in Security Prices (CRSP) data files a Haver Analytics data files © International Monetary Fund data files 0 Organization for Economic Cooperation and Development data files. PROC CITIBASE reads time series from the CITIBASE files and converts them into a SAS data set. Note that the capabilities of PROC CITIBASE are a subset of PROC DATASOURCE. PROC CITIBASE can read QO tape-format CITIBASE data files a diskette-format CITIBASE databases c Haver Analytics data files For more information on the CITIBASE and DATASOURCE procedures, see SAS/ETS User’ s Guide, Version 6, Second Edition. Single-Period Return Measure Single-period return measures consist of two parts: income derived from dividends and capital gains (or losses) derived from selling the stock at a greater (lesser) price than the purchase price. When you buy shares of stock (at time t — /), hold them, then sell them (at time f), you earn the difference between the buying price (P,.;) and the selling price (P,) plus any dividends (D,) issued for that stock. Returns can be measured as dollar earnings or as a percentage of the amount invested. Thus, the stock return for the ith stock for the rth period (Rj,;) is measured as follows (ignoring commission and other brokerage firm charges): 4 Single-Period Return Measure 2 Chapter 1 When you expect a stock price to fall, you can sell it, even though you do not own it. Sales of this type are known as short sales. Typically, stockbrokers provide the stock required for the short sale, and they request collateral for the period the stock remains short. When you believe the stock price has reached its lowest point, you purchase shares at the lower price. The return on your short sale is calculated as shown in the previous equation. Introducing the SP1 Data Set The SP1 data set consists of the Standard and Poor’s (S&P) 500 Composite Stock Index for the years 1970 through 1989, where the period 1941 through 1943 is equal to 10 and the stock dividends are in index form. Note that indexes of stocks are typically weighted by dollar value of outstanding shares. The following DATA step creates the SP1 data set and labels the variables. Explanation of Syntax DATA data-set-name begins the DATA step and creates a SAS data set named by the specified data-set-name. For this example, the data set is named SP1, INPUT reads the input data, then creates and names the SAS variables. For this example, the INPUT statement reads the values of the S&P index and creates the variables V and D. The double trailing at symbol (@@) indicates that each line of data contains more than one observation. LABEL labels the variables. CARDS indicates that data lines follow. The semicolon that follows the data lines causes the DATA-step statements to execute. Example code data spl; input year v d @@; label v='End-of-Year Index Value’ d='Dividends'; cards; 1970 92.15 3.14 1971 102.09 3.07 1972 118. 1973 97.55 3.38 1974 68.56 3.60 1975 1 1976 107.46 4.05 1977 95.10 4.67 1978 96. 1979 107.94 5.70 1980 135.76 6.16 1981 122. 1982 140.64 6.87 1983 164.93 7.09 1984 167. 1985 211.28 7.90 1986 242.17 8.28 1987 247. 1988 277.72 9.73 1989 353.40 11.05 run; You print variables in the SP1 data set with the PRINT procedure. The following statements print the first five observations. The results are shown in Output 1.1. Output 1.1 First Five Observations of the SPI Data Set Background Topics O Single-Period Return Measure 5 Explanation of syntax PROC PRINT invokes the PRINT procedure. The following options of the PROC PRINT statement are specified: DATA= specifies the data set to be printed. This example specifies the SP1 data set. The OBS=n option specifies that the first n observations be printed. In this example, the OBS= option specifies that the first five observations be printed. LABEL specifies that the variable labels be printed. VAR specifies the variables to be printed. TITLE titles the output. In this example, three title statements are used; however, you can use up to ten title statements. In interactive SAS sessions, TITLE statements remain in effect until they are changed or until the SAS session ends. Example code proc print data=spl(obs=5) label; var year v d; title ‘Background Topics’; title2 ‘Printing the SP1 Data Set’; title} 'First Five Observations’; run; Background Topics Printing the SP1 Data Set First Five Observations End-of-Year Index Value Dividends 92.15 102.09 118.05 97.55 68.56 Interpretation of output In Output 1.1, the values of the first five observations of the variables YEAR, V, and D are printed. By printing data sets, you can check for coding errors in the input values and for the appropriate number of observations. 6 Single-Period Return Measure 0 Chapter 1 Output 1.2 Plotting Index and Dividend Values versus Time in Years Plotting the SP1 Data Set Plotting the data versus time is often the first step in analyzing a time-series data set. You use the PLOT procedure to create scatter plots. The following PROC PLOT statements plot the Standard and Poor’s Index values and the dividend values versus time in years. The results are printed in Output 1.2. Explanation of syntax PROC PLOT invokes the PLOT procedure. The following options of the PROC PLOT statement are specified. DATA= specifies the data set to be used. VPCT= specifies the percentage of the SAS output page for the vertical height of the plot. PLOT specifies the vertical axis variable to be plotted versus the horizontal axis variable. In this example, two PLOT statements are used to request one plot each. Example Code proc plot data=spl vpct=150; plot v*year; plot d*year; title2 ‘Plotting Data Values versus Year’; titles; run; Background Topics Plotting Data Values versus Year Plot of V*YEAR. Legend: A = 1 obs, B = 2 obs, etc. 400 300 + 1 I I + I I | 200 + a ' | 1 100 + 1 t 1 + wengeneneeee tonsenan tooneanee toonenene. toveeeea fonnnnnne. rosesnns to 1968 = 1971_-« «1974 = «1977 38019831986 1989 Background Topics © Single-Period Return Measure 7 Background Topics Plotting Data Values versus Year Plot of D*YEAR, Legend: A = 1 obs, B = 2 obs, etc. D a i v A i AA a A e AAA a a a a 8 aA A AA nonenngnnennnnngene aentesenenenten 1977 198019831986 = 1989 Interpretation of output The two plots in Output 1.2 indicate that both the Index values and the dividend values are following an overall upward trend. In general, plotting data can reveal trends and seasonal variation, which may be important for later analysis. Calculating Single-Period Returns You calculate the single-period returns in a DATA step. The SET statement reads observations from the specified data set. In the following example, observations are read from the SP1 data set. The assignment statements create new variables using the previously created variables and DATA-step functions. In this example, three new variables are created: V_1,R, and R_PER. V_1 is the lagged value of V; R is the returns; and R_PER is R in percentage terms. The input data, the variables used for intermediate calculations, and the returns are printed in Output 1.3. /* Calculating the Single Period Returns */ data sp2; set spl; v_islag(v); rs(v-v_1+d) /v_1; r_per=r*100; label v_l=’Lagged Index Value’ r='Returns’ r_per='Percentage Returns’; run; /* Printing Single Period Returns */ proc print data=sp2 label; var year v v_l dr r_per; title2 ‘Printing the Single Period Returns’; run; 8 Single-Period Return Measure 9 Chapter I Output 1.3 Raw Data, Intermediate Steps, and Single-Period Returns Background Topics Printing the Single Period Returns lagged End-of-Year Index Percentage YEAR Index Value Value Dividends ©=—Returne ©=—sReturne 92.15 : . : i‘ 92.15, ) -14118 14,1183 102.09 . 18719 18.7188 118.05 . 14502 -14,5023 97.55 z 26028 = -26.0277 68.56 . 36917 36.9166 90.19 : +23639 23.6390 107.46 . 07156 7.1562 95.10 . -06393, 6.3933 96.11 . 18240 18.2395, 107.94 3. 31480 31,4805, 135.76 : 04847 4.8468 122.55 : 20367 20,3672 140.54 : +2312 22.3123 164.93, : + 05966 5.9662 167. : -31057 33.0572 211. . +18539 18.5394 242. . 05665, 5.6654 247, : +16339 16.3388 271. . 31229 31.2293 Interpretation of output In Output 1.3, the values of the input data and the annual returns are printed. Note that missing values are represented by a period (‘*.”). Missing values appear for the 1970 values of the return and percentage return because those values depend on the lagged index value, which is also missing. Also note that the Standard and Poor’s 500 Composite Index has annual returns that range from a low of -.26028 (in 1974) to a high of .36917 (in 1975). Holding stocks (or a portfolio of stocks) over time raises questions such as “What is the average return over multiple periods?” and “How does compounding affect the average return over multiple periods?” The section “Multiple-Period Return Measures,” later in this chapter, presents multiple-period return measures. Plotting Returns After calculating returns, you may want to use PROC PLOT to plot them versus time to visually assess trends across time. The following PROC PLOT statements plot the returns versus time in years. The VREF= option specifies that a vertical reference line be drawn perpendicular to the vertical axis at the specified value, which for this example is zero. The results are shown in Output 1.4. proc plot data=sp2 vpct=150; plot r*year / vref=0; title2 ‘Plotting Returns versus Year'; run; Background Topics 0 Multiple-Period Return Measures 9 Output 1.4 Plotting Returns versus Time in Years Background Topics Plotting Returns versus Year Plot of R*YEAR, Legend: A = 1 obs, B = 2 obs, etc. eBNeaom senteneeneee toeceeees! toveennne: fooeeeeas fonnnanee. foonennss) focceeens) to 1968 = 1971-1974. 1977 = 19801983 1986 = 1989 YEAR ——SSS—= Interpretation of output In Output 1.4, the plot of the returns versus time shows that there are more positive returns than negative returns and that there are no obvious trends across time. The plot also suggests the possibility of greater dispersion in the data in the 1970s than in the 1980s, and further analysis would be required to corroborate the visual assessment. Multiple-Period Return Measures Multiple-period return measures involve calculating arithmetic and geometric averages from the single-period returns. Thus, in assessing stock returns over several periods, the following measures are of interest. The arithmetic mean (AM) is simply the sum of the returns over several time periods divided by the number of individual returns (T). The arithmetic mean measures the average (or typical) return over individual periods. The wealth index (WEALTH) indicates the wealth generated (or lost) by investing. For example, if you invest $1 in shares of a stock at the beginning of the year, the wealth index (over the 12 monthly returns or 52 weekly returns) indicates the value at the end of the year. If the wealth index is greater than unity, the value of the portfolio increased. If the wealth index is less than unity, the value of the portfolio decreased. The wealth index for T periods is calculated by the following equation: WEALTH = (1 +R,) x (1+R,) x... x (1+R,) 10 Muiriple-Period Return Measures 0 Chapter | Note that the wealth index is also equal to the ending-period value of the investment (Wy) divided by the initial investment (Wp): W, WEALTH = 7 The geometric mean reflects compound, cumulative returns over time and, over T periods, is defined as follows: Geometric Mean = (( +R)x(1FR)x...x (1+ Rf" i Geometric Mean = (WEALTH)' You use the geometric mean of the returns to calculate the average rate of return over multiple periods. The average compound return (GM) measure for T periods is calculated as follows: oM=[(1+R)x(1+R)x...x(14R)) 7 1 wer GM =(WEALTH) - 1 Calculating Multiple-Period Return Measures You can calculate multiple-period return measures for the SP2 data set. For example, suppose you want to calculate the wealth index, the arithmetic and geometric mean measures, and the percentage values of the mean measures for the period 1985 through 1989 for the data in the SP2 data set. To perform this task, 1. use a DATA step to create a new data set containing the proper subset of the data 2. use the TRANSPOSE procedure to transpose the data for ease in calculation 3. use a second DATA step to calculate the return measures. Subsetting a Data Set The following DATA step creates a new data set containing the data for the years 1985 through 1989. Explanation of syntax DATA begins the DATA STEP and creates a new data set named SP3. SET reads observations from the specified data set. In this example, observations are read from the SP2 data set. WHERE specifies a condition that the data must satisfy before the observations are processed. Using the WHERE statement improves the efficiency of your SAS programs because Background Topics 2 Muttiple-Period Return Measures 11 only the qualifying observations are read from the input data set. In this example, the where condition for reading observations is that the value for the variable YEAR be greater than or equal to 1985. Example code data sp3; set sp2; where year ge 1985; run; These statements produce no printed output. Transposing a Data Set You use PROC TRANSPOSE to transpose data sets. When a data set is transposed, its rows become columns and its columns become rows. In terms of SAS data sets, the observations become variables and the variables become observations.The following statements transpose the SP3 data set. Explanation of syntax PROC TRANSPOSE invokes the TRANSPOSE procedure. DATA= _ specifies the data set to be transposed. OUT= creates and names the output data set. VAR specifies the variables to be transposed. Example code proc transpose data=sp3 out=sp4; var rj run; You print the SP4 data set with the following PROC PRINT statements. Output 1.5 shows the results of this example. proc print data=sp4; title2 'Printing the SP4 Data Set’; run; Output 1.5 Background Topics Printing the SP4 Printing the SP4 Data Set Data Set LABEL COLL. con coL3 cond cous Returns 0.31057 0.18539 0.056654 0.16339 0.31229 12 Multiple-Period Return Measures G Chapter 1 Interpretation of output In Output 1.5, the values of the SP4 data set are printed. PROC TRANSPOSE labels the columns (that is, the variables) of the transposed data set, COL1 through COL». For this example, the variables labeled COL1 through COLS represent the index returns from 1985 through 1989. Calculating Return Measures You can calculate the following multiple-period measures of return using a DATA step and the SP4 data set: wealth index (WEALTH) © arithmetic mean in level form (AM) Q arithmetic mean in percentage form (AM_PCT) average compound rate of return in level form (GM) average compound rate of return in percentage form (GM_PCT) The following DATA step performs these calculations. The variables C1 through C5 are created for ease in calculating the wealth index and the average compound rate of return. data sp5; set sp4; t=5; cl=coll+1; c2=col2+ c3=col3+1; c4=col4+1; c5=col5+1; wealth=(cl*c2*c3*c4*c5) ; gm=( (wealth) **(1/t))-1; gm_pct=gm*100; am=mean (of coll-col5); am_pct=am*100; run; For larger numbers of variables, array processing is a more efficient way of coding. The following DATA step performs the same tasks using array processing in an iterative DO loop. The variables C1 through C5 are created from the variables COL1 through COLS. Explanation of syntax ARRAY creates a temporary grouping of variables. Arrays enable you to efficiently apply the same process to each of the variables in the group. A simple ARRAY statement has the following form: ARRAY array-name (number-of-elements} list-of-variables; In this example, two arrays are created (COL and C); each consists of five variables. Output 1.6 Multiple-Period Return Measures Background Topics G Multiple-Period Return Measures 13 DO... END specifies that the same action be performed several times. An iterative DO loop begins with an iterative DO statement, contains other SAS statements, and ends with an END. statement, as shown in the following syntax: DO index-variable=1 TO number-of-variables-in-array; more SAS statements END; Example code data sp5a; set sp4; t=5; array col(5} coll-col5; array c(5) cl-c5; do i=1 to 5; c(i) = col{i) + 1; end; wealth=(cl*c2*c3*c4*c5) ; gm=(wealth**(1/t))-1; gm_pct=gm*100; am=mean(of coll-col5); am_pct=am*100; run; For more information on ARRAY processing in iterative DO loops, see SAS Language, Reference, Version 6, First Edition (pages 160-171) and SAS Language and Procedures, Usage (pages 178-182), and SAS Language and Procedures, Usage 2 (pages 143 and 144). The following PROC PRINT statements print the multiple-period return measures. proc print data=sp5; var wealth gm gm_pct am am_pct; title2 ‘Multiple Period Return Measures’; run; Background Topics Multiple Period Return Measures ops = WEALTH om cu_pcr aM AM_PCT 1 -2,50618 0.20172 20.1717 0.20566. «20.5660 Interpretation of output In Output 1.6, the return measures are printed. The wealth index value (WEALTH) of 2.50618 indicates that $1 invested in the Standard & Poor’s 500 Composite Stock Index in 1985 would have grown to about $2.51 by 1989. So for example, if you had invested $25,000 in the S&P Index in 1985, your investment would have grown to $62,654.50 in 1989. Both the arithmetic mean (AM) and the average compound growth rate (GM) are over .20, while the percentage values (AM_PCT and GM_PCT) are over 20 percent. These 14 Calculating Expected Returns 0 Chapter 1 values indicate that the average growth rate for an investment in the S&P Index was over 20 percent per year. Calculating Expected Returns Stock analysts calculate past stock returns to evaluate the historical performance of stocks, which provides a benchmark measure for future returns. But for the purpose of investment, stock analysts need to estimate future returns. You can pursue many approaches for estimating the level of future returns, including those in the following table: Table 1.1 Approaches for Calculating Expected Returns To follow this approach, Approach Appropriate if research indicates... use... Use the mean value of distribution of returns is constant and future returns PROC MEANS past returns. are expected to be quite similar to the average of past returns. Calculate the mean. a set of particular values and probabilities for their DATA step and PROC value from a discrete occurrence. MEANS distribution. Calculate a growth rate and extrapolate into the future. Fit a regression model and use the forecasted values. Fit a time series model to the past values and forecast future values. past growth trends are stable and will continue in the DATA step future. returns are correlated with one or more variables so PROC REG, PROC MODEL, that as these variables change, the returns also change. or PROC SYSLIN returns have seasonal patterns or identifiable trends PROC ARIMA, PROC over time. AUTOREG, or PROC FORECAST This section discusses the first three approaches, while the fourth approach is discussed in Chapter 4, “The Capital Asset Pricing Model (CAPM).” (The last approach is beyond the scope of this text.) Calculating Mean Return Values You can use the MEANS procedure to calculate the mean and other statistical summary measures. The following statements calculate the mean values for the variables R and R_PER from the SP3 data set. The results are shown in Output 1.7. Output 1.7 Arithmetic Mean Return in Level and Percentage Form Background Topics O Calculating Expected Returns 15 Explanation of syntax PROC MEANS invokes the MEANS procedure. The following options of the PROC MEANS statement are specified. DATA= __ specfies the data set to be used in the analysis. MEAN specifies that the mean values be calculated for the listed variables. VAR specifies the variables to be used in the analysis. Example code proc means data=sp3 mean; var r r_per; title2 ‘Mean Returns’; run; Background Topics Mean Returns R Returns 0.2056602 RPER Return Percentage 20 Interpretation of output In Output 1.7, the return measures are printed. These are the same values calculated in Output 1.6 for the variables AM and AM_PCT. However, in Output 1.6 additional values were calculated (GM, GM_PCT, and WEALTH). For larger data sets, and for the calculation of summary statistics, PROC MEANS is more efficient. Calculating the Mean of a Discrete Distribution Your research may indicate that a stock has returns that follow a discrete distribution. That is, you expect the stock to have returns of various amounts with specified probabilities (and the probabilities are nonnegative and sum to unity). For example, you may expect returns of a stock to be .02 with a 20 percent chance, .015 with a 40 percent chance, and .01 with a 40 percent chance. The mean of this discrete distribution is Mean Return = (.02 x .2) + (.015 x .4) + (.01 x .4) Mean Return = .004 + .006 + .004 = 014 or 1.4% 16 Calculating Expected Returns O Chapter 1 Table 1.2 Discrete Distribution of Stock Returns and Specified Probabilities The calculations for one stock are trivial; however, your analysis may involve hundreds or even thousands of stocks. The following table shows multiple stocks, where the returns are expected to follow the listed values with the specified probabilities: Probabilities Return Stock 1 Stock 2 Stock 3 Stock 4 -.05 05 10 0 10 0 .25 .20 -20 10 05 40 30 30 .20 10 -20 .20 30 30 AS 10 10 .20 20 20 0 05 0 10 Each stock has its own discrete distribution of returns. The expected return for each stock is the mean of its discrete distribution, which is the sum of a linear combination of the returns (Rj j) and their respective probabilities (P;,j). Thus, the mean return of a discrete distribution of expected returns for the ith stock is i MeanReturn. = 5 P.XR ah i To calculate the mean of a discrete distribution, use the DATA step and PROC MEANS. The following DATA step creates the D1 data set and uses array processing to calculate linear combinations (LC1 through LC4) of the returns (R) and the probabilities (P1 through P4). The results are not shown. data dl; input r pl p2 p3 pd; array pl4) pl-p4; array 1c(4) lcl~1c4; do i=l to 4; le(i)=r*p li); end; cards; -.10 0 .05 0 0 -.05 05 .10 0 .10 0 25 620 .20 .10 Output 1.8 Discrete Distribution Mean Returns Background Topics 0 Calculating Expected Returns 17 -05 .40 .30 .30 .20 +10 620.20 .30 30 +15 610) 610.20 20 20 0 .05 0 .10 The following PROC MEANS statements calculate the mean values. The results are shown in Output 1.8. Explanation of syntax PROC MEANS invokes the MEANS procedure. The following options of the PROC MEANS statement are specified: SUM sums the observations of the listed variables. For this example, the variables LCI-LC4 are summed. They are the product of the returns and probabilities. NOPRINT suppresses the printed output. OUTPUT creates the output data set OUT_D1, which is named in the OUT= option. OUT_D1 contains the mean values for the variables MEANI_MEAN4. Example code proc means data=d1 sum noprint; var lcl-1c4; output out=out_d1 sum=-mean1-mean4; run; proc print data=out_dl; var meanl-mean4; title2 ‘Discrete Distribution Mean Returns’; run; Background Topics Discrete Distribution Mean Returns ops = MEAN» MEAN2 = MEAN3-MEANG 1 0.0525 «0.050.075 0,085. Using a Growth Rate to Calculate Expected Returns Your research may indicate that the returns of a stock have grown at a constant rate and appear to be continuing at that rate. This growth rate can be used to calculate values for future returns. For example, you can use the last return value in the series and multiply it by the sum of the growth rate plus 1 to calculate the next value in the series. 18 Calculating Expected Returns Chapter 1 There are several growth rates that may be appropriate, including the following: © arithmetic mean in level form (AM, as discussed previously) © average compound rate of return in level form (GM, as discussed previously) G__ linear or higher-order polynomial functions of time 9 nonlinear functions of time; for example, logistic curves. The first two growth rates listed are calculated in the statements producing Output 1.6; the third approach is discussed in Chapter 2 for dividend growth rates; while the fourth approach is beyond the scope of this book. This example uses the first two growth rates listed. The SPS5 data set is used for illustrative purposes. Note that the returns in the SPS data set have not grown at a constant rate, as shown previously in the plot of Output 1.4. Use the following DATA step to calculate these growth rates and to calculate returns for the next year. Note that the variable COLS contains the return for the last period in the series, 1989, The future return values are printed using PROC PRINT in Output 1.9. /* Calculating Next Period's Return */ data sp6; set sp5; ram = col5*(am+1); r_gm = col5*(gm+1); run; /* Printing Calculated Returns */ proc print data=sp6; var col5 r_am r_gm; title2 ‘Future Returns’; title3 ‘Calculating with Past Growth Rates’; run; Output 1.9 Background Topics 1989 Return (COLS) Future Returns and 1990 Returns calculating with Past Growth Rates Calculated from ops cous RAM RGM Constant Growth Rate 1 0.31229 0.37652 0.37529 Interpretation of output In Output 1.9, the 1989 return value (labeled COLS) and the calculated return values for 1990 (R_AM and R_GM) are printed. By either growth rate (arithmetic average or annually compounded), the future value is the largest in the series over the period 1970-1990, as shown previously in Output 1.3. This approach should be used with constant-growth return series and for calculating the next-period return value. This approach should not be used with return series that grow at different rates, nor for calculating expected returns far into the future. For example, if this approach were used (with this data set) to calculate the return values for the year 2000, the expected returns are well over 225 percent. Background Topics © Risk Measures 19 Risk Measures Knowing the past returns and the expected return for financially investing in a stock is rarely sufficient. Stock analysts realize that risk accompanies investments. Investors weigh the expected returns and risk in making investment decisions. Investment literature classifies risk into categories, including O systematic or market risk, which is risk associated with the movements of the market portfolio (for example, the Standard & Poor’s 500 or the Dow Jones Industrials). Systematic risk is also known as nondiversifiable because owning additional assets cannot reduce this risk; that is, it cannot be diversified away. 0 nonsystematic or nonmarket risk, which is risk associated with factors other than the movement of the market (for example, industry and firm-specific factors that affect stock yeturns). Nonsystematic risk is also known as diversifiable risk because owning additional assets reduces this risk; that is, it can be diversified away. additional risk catagories: Interest Rate Risk is fluctuations of interest rates that affect the present values of future returns. As interest rates increase (decrease), the present value of a future return decreases (increases). Interest rate fluctuations affect a firm’s decision to finance operations by stock issues or bond issues and the mix of the two. In general, the larger and more rapid the shifts in interest rates, the greater the effect on investors” calculations. Inflation Risk is fluctuations of inflation rates that affect the purchasing power of currencies. The larger and more unexpected the change in the inflation rate, the greater the impact on investors’ decisions and their evaluation of previous investments. Currency Risk ; is fluctuations of relative currency values (through changes in exchange rates) that affect international investing decisions. Currency appreciation and depreciation can greatly affect the returns received by the investor. Total risk includes all the components of risk and is typically measured by the standard deviation of the distribution of returns. Often, investors use past returns as a representative sampling of the distribution of returns. Alternatively, you may want to use a discrete distribution of future returns (that is, specific returns with specified probabilities). The following sections present an example of each. Calculating Risk from Historical Data For stock analysts, risk is most often measured by the standard deviation of a stock’s returns. The standard deviation is the square root of the variance, and the sample variance is defined as follows: 20 Risk Measures © Chapter I Output 1.10 Mean, Variance, and Standard Deviation You can calculate the standard deviation of the returns in the SP3 data set using PROC MEANS. The following PROC MEANS statements calculate the mean, variance, and standard deviation with the MEAN, VAR, and STD options, respectively. The results are printed in Output 1.10. proc means data=sp3 mean var std; var ¥; title2 'Mean, variance, and Standard Deviation’; title3; run; Background Topics Mean, Variance, and standard Deviation Analysis Variable : R Returns Mee Calculating Risk from Discrete Distribution A measure of expected risk can be obtained by listing the expected returns (Rj j) and the probabilities (P) of achieving them and then calculating the standard deviation of the distribution. For example, you calculate the risk (standard deviation) of the stock returns listed in the D1 data set with the following formula: a) You use the DATA step and PROC MEANS in the following steps to calculate the risk level (standard deviation) of a discrete distribution of expected returns. For this example, you use the returns and probabilities of the four stocks in the DJ data set and the distribution mean values contained in the OUT_D1 data set: Risk =o =D Px (R Tasks performed by the Program 1, Use a DATA step to create additional observations of the OUT_D1 data, which contains. the mean values, For this example, there are seven observations in the D1 data set; therefore, you need seven observations in the OUT_D1 data set. 2. Use another DATA step to merge the D} and OUT_D2 data sets, and use array processing in an iterative DO LOOP to create the intermediate-step variables VV1 through VV4. 3. Use PROC MEANS to sum the intermediate-step variables for calculating the variances and to store them in an output data set, OUT_D3.

You might also like