LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (June 2006, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 20 Jun 2006 09:26:21 -0400
Reply-To:     "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Subject:      Re: WKret

On Tue, 20 Jun 2006 05:11:21 -0400, Thomas <tythong@YAHOO.COM> wrote:

>On Mon, 19 Jun 2006 08:55:08 -0400, Howard Schreier <hs AT dc-sug DOT org> ><nospam@HOWLES.COM> wrote: > >>It would be better to have an example of the desired output and a display >of >>the code which has been tried, or at least an explanation of whatever >>approaches have been considered. >> >>Nayway, here's a possibility: >> >> proc sql; >> create table want as >> select com, >> intnx('week.5',date,0) format weekdate. as Thursday, >> exp(sum(log(ret+1) ) ) - 1 as compound_ret >> from have >> group by com, thursday >> having weekday(min(date) )=5 >> and weekday(max(date) )=4; >> quit; >> >>Result: >> >> Obs COM Thursday ret >> >> 1 KO Thursday, March 4, 1999 0.02028 >> 2 KO Thursday, March 11, 1999 0.06519 >> 3 KO Thursday, March 18, 1999 -0.02152 >> 4 MSFT Thursday, January 7, 1999 -0.04917 >> 5 MSFT Thursday, January 14, 1999 0.13081 >> 6 MSFT Thursday, January 21, 1999 0.03689 >> >>On Sun, 18 Jun 2006 11:56:13 -0400, Thomas <tythong@YAHOO.COM> wrote: >> >>>Hi all, >>> >>>May I know how to compound the returns (ret) from Thursday to Wednesday >>>for the following dataset? The daily returns are actually compounded from >>>Thus to Wed into weekly returns for each company (COM). Your kind help >>>will be greatly appreciated. >>> >>>Thank you very much! >>> >>>Best regards, >>>Thomas >>> >>>/*DATASET*/ >>>date COM RET WEEKDAY >>>19990104 MSFT 0.016674178 2 >>>19990105 MSFT 0.039007094 3 >>>19990106 MSFT 0.032423209 4 >>>19990107 MSFT -0.004958678 5 >>>19990108 MSFT -0.004152824 6 >>>19990111 MSFT -0.015846539 2 >>>19990112 MSFT -0.036016949 3 >>>19990113 MSFT 0.011428571 4 >>>19990114 MSFT -0.014341591 5 >>>19990115 MSFT 0.056437388 6 >>>19990119 MSFT 0.039232053 3 >>>19990120 MSFT 0.044979919 4 >>>19990121 MSFT -0.026518064 5 >>>19990122 MSFT -0.01302803 6 >>>19990125 MSFT 0.035999998 2 >>>19990126 MSFT 0.059845559 3 >>>19990127 MSFT -0.01712204 4 >>>19990128 MSFT 0.031875465 5 >>>19990129 MSFT 0.005747126 6 >>>19990301 KO -0.002935421 2 >>>19990302 KO -0.024533857 3 >>>19990303 KO -0.008048289 4 >>>19990304 KO 0.021298174 5 >>>19990305 KO 0.015888778 6 >>>19990308 KO 0.000977517 2 >>>19990309 KO -0.015625 3 >>>19990310 KO -0.001984127 4 >>>19990311 KO 0.058210734 5 >>>19990312 KO 0.046139359 6 >>>19990315 KO -0.01080108 2 >>>19990316 KO 0 3 >>>19990317 KO -0.027297543 4 >>>19990318 KO 0.021515435 5 >>>19990319 KO -0.010989011 6 >>>19990322 KO 0.002777778 2 >>>19990323 KO -0.02677747 3 >>>19990324 KO -0.007590133 4 >>>19990325 KO 0.007648183 5 >>>19990326 KO -0.008538899 6 > >Hi Howard, > >Thanks lot! May I know if Thursday is a holiday (i.e, missing observation >for Thursday), does PROC SQL take the subsequent non-holiday observations >(i.e., maybe start from Friday, Monday, so on and so for) for compounding >in order to complete the weekly returns?

SQL of course does what one tells it to do.

I coded to require presence of the end-point days (Thursday and Wednesday) because I saw in the sample data that there were incomplete Thursday-to-Wednesday weeks at the beginning and end of each series, and I assumed that those weeks should be excluded.

You can of course tweak the code as needed; consult the PROC SQL documentation as necessary.

>I would very much appreciate it, if you could kindly advise me again at >your convenience. > >Thanks again & warm regards, >Thomas


Back to: Top of message | Previous page | Main SAS-L page