Good days to all, I have a dataset (as attached) with the following variables; gvkey = company identification code fyear = financial year IB_LAT = earnings CFO_LAT = cash flows ACCR_LAT = accruals I wish to calculate the following variables: SMTH1 is the standard deviation of earnings (IB_LAT) divided by the standard deviation of cash flows (CFO_LAT), where standard deviations are calculated using a minimum of three and maximum of five years of data (t-4 to t); SMTH1 is multiplied by negative one so that larger values, i.e., values closer to zero, represent smoother earnings. SMTH2 is defined as the correlation between the cash flows (CFO_LAT) and total accruals (ACCR_LAT), correlations are calculated using a minimum of three and maximum of five years of data (t-4 to t); SMTH2 is multiplied by negative one so that larger values, i.e., values closer to one, represent smoother earnings. I intend to use either DATA step or Proc Expand to calculate the variables. However, I have no idea how to ensure I have at least 3 years of data available to fulfill such definitions. *t-4 to t = 5 years = lag4(x), lag3(x), lag2(x), lag1(x), x. Is the option for "correlation" available in proc expand? I found a blog that is close to my query: Rolling Correlation Window [Archive] - Statistics Help @ Talk Stats Forum By referring to proc expand user guide: SAS/ETS(R) 9.3 User's Guide, the following commands are available, I'm not sure to what extend these codes can be applied to my case: > number Missing value if , else x >= number Missing value if , else x = number Missing value if , else x = number Missing value if , else x < number Missing value if , else x <= number Missing value if , else x Thank you and hope to get any help. Regards, mspak
... View more