BookmarkSubscribeRSS Feed
Quannguyen
Calcite | Level 5
Hi. I’m very new to SAS and want to ask a question.
I have 2 data set, 1 has the announcement date for the M&A deal, second has the date and federal rate. I need to find the mean and standard deviation of the rate with in 125 days prior to the announcement date.
Can you guys help me with this?
12 REPLIES 12
qoit
Pyrite | Level 9

Hi, are you able to post the first few observations of the datasets? It seems like you need to

 

  1. join the datasets first
  2. Use PROC MEANS to calculate the Standard Deviation and Mean as 

PROC MEANS DATA=my_dataset (WHERE = (announcement_date >= INTCK('DAY',announcement_date,-125,'s')) STD MEAN;

VAR rate;

RUN;

Quannguyen
Calcite | Level 5
3000285MMAir Methods Corp.American Securities LLC1164103/14/2017Complete.04/21/20171Cash01000017892376010.01163001212TRANSOTHER
23000547MMKCG Holdings, Inc.Virtu Financial, Inc.1399803/15/2017Complete.07/20/20170Cash01000.62615794-010.011420-01111FINFIN
33001983MMStonegate BankHome Bancshares, Inc. (Arkansas)1467103/27/2017Complete
106/30/20021.73
207/01/20021.83
307/02/20021.72
407/03/20021.71
507/04/20021.71
607/05/20021.72
707/06/20021.72
807/07/20021.72
907/08/20021.75
1007/09/20021.72
1107/10/20021.74
1207/11/20021.76

 

 
Quannguyen
Calcite | Level 5

Hi. Can you see the table? I wonder if you can show me how to join two tables as well

qoit
Pyrite | Level 9
I am unable to tell which dataset is which? Are you able to attach a few rows in a tabular format of both datasets?
Quannguyen
Calcite | Level 5

Quannguyen_0-1613017947504.png

Quannguyen_1-1613017967176.png

here are two screenshots of them

 

 

qoit
Pyrite | Level 9

It is assumed that both the datasets can be joined using "Announcement Date" in dataset1 and "Date" in dataset2. I could not find an ID Variable in dataset2:

 

proc sql;
	create table dsn as
		select data1.deal_id,data1.announcement_date,data2.date,data2.rate
			from dataset1 as data1 
				inner join /* Assuming we only need common observations i.e. which exists in both datasets*/
	dataset2 as data2
	on data1.announcement_date = data2.date;
quit;

PROC MEANS DATA=dsn(WHERE=(nannouncement_date >= INTCK('DAY',announcement_date,-125,'s'))) STD MEAN;
	VAR rate;
RUN;
Quannguyen
Calcite | Level 5

So in the announcement_date dataset, there are 640 observations while in the rate dataset there are 40,000+ observations. So I don't know how to join them. Basically, I need to find the average rate for 640 deals which range 125 days before the announcement date. I don't know if it makes sense?

qoit
Pyrite | Level 9
Would you know if the Deal_ID variable (column) exists in the dataset2 (rate dataset)? We need a common unique variable to join both datasets.

In the rate dataset, how do we know which rate belongs to which Deal_id?
Quannguyen
Calcite | Level 5
No. I don’t. The second dataset only has date and federal rates. So the rate of the announcement deal = mean(federal rate 125 days prior to the announcement date).
qoit
Pyrite | Level 9
In order to get the federal rate for a particular announcement date, we need a common variable to join both datasets. Apologies, either you need to attach 100 rows of both datasets in here for others to assess or gain further clarity from whoever provided you with the data.
Quannguyen
Calcite | Level 5
Yeah. The date is the only thing that can use to join 2 datasets. So basically the first dataset has deal_id and announcement_date and the second dataset has date and federal date.
The rate for the deal in dataset 1 = the average rate( from dataset2) of 60 days prior to the announcement date. For example: company A has the announcement date 4/1/2019. So the rate for company A = mean of the federal rate from 1/1-4/1/2019
andreas_lds
Jade | Level 19

Sorry, but screenshots are even more useless than tables. Both don't show relevant information like variable types, length etc. So please take your time and post data in usable form. Have a look at How to convert datasets to data steps if you don't know what to do.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 12 replies
  • 926 views
  • 0 likes
  • 3 in conversation