BookmarkSubscribeRSS Feed
Francesco1
Calcite | Level 5

Hi there,

 

I have weekly return data for each company, I would like to write a SAS code that can take the mean of the weekly returns for each company in the dataset. 

 

My data looks like:

 

DATE                              COMPANY                                       RETURN

5/2/2014                         A                                                       0.01

12/2/2014                       A                                                       -0.05

19/2/2014                       A                                                       0.02

.......                               

5/2/2014                         B                                                        0.02

12/2/2014                       B                                                        0.01

19/2/2014                       B                                                        -0.01

.........

 

 

After deducing the mean, I would also like to deduce standard deviation of returns for each company and seeing if any of the returns for each company are < 3.09 standard deviations in which case I would like insert a CRASH dummy variable of "1" for that company during that year, otherwise "0" .

 

Any help or ideas will be greatly appreciated.

 

Thanks.

1 REPLY 1
Reeza
Super User

What's a week to you?

 

proc means data=have nway mean std stackods;
class stock date;
format date weeku.;
var return;
ods output summary=want;
run;

proc print data=want;
run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1 reply
  • 523 views
  • 0 likes
  • 2 in conversation