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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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