BookmarkSubscribeRSS Feed
Fred_Gavin
Calcite | Level 5
I recently encountered the problem in a stock even study. The pseudo data looks like
DATE Index Volume StockReturn ReturnInterval
19990101 0.1 200 0.02 .
19990102 0.32 300 0.03 1
19990103 0.2 0 0 .
19990104 0.1 200 0.04 2
19990105 0.22 0 0 .
19990108 0.03 0 0 .
19990109 0.2 100 0.01 3
Here the volume 0 means on that day, the stock is not traded, but we still have the index return for the overall market. The return interval gives the number of returns between two traded dates. What I want to do is to sum of the index return over each return interval. ie: on day 19990102, the new index is itself 0.32, on day 19990104, the new index return should be 0.2+0.1, and on day 19990109, the new index return should be 0.22+0.03+0.2.

I hope any ppl can help me with this.. Heaps Thanks here first.
2 REPLIES 2
deleted_user
Not applicable
this looks too much in need of the original data order to be suitable for SQL. However, the DATA STEP can easily use the ordered information:[pre]data idx_ret_sums( keep= DATE idx_ret_sum ) ;
set pseudo_data ;
idx_ret_sum + Index ;
if not missing( returnInterval ) ;
output ;
idx_ret_sum = 0 ; * prepare accumulator for next interval;
run ;
proc print ;
run;[/pre]

PeterC
Fred_Gavin
Calcite | Level 5
Hi Peter, Thanks so much.. I will test on my whole data soon, but i am sure it gonna work well.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 528 views
  • 0 likes
  • 2 in conversation