BookmarkSubscribeRSS Feed
namrata
Fluorite | Level 6

I need to regress the monthly returns of each firm(180 obs for each firm) on the returns of a particular commodity for that period(180 observations).

I have the data ready: one sheet containing returns of several companies and the commodity returns on the other hand.

While regressing in SAS, do I paste the returns of the commodity against each firm manually on the worksheet or is there some code in SAS that can directly regress each firm's returns on the commodity returns?

Right now,the data sheet looks like:

date     firm       firmret     commodityret

1          a          10               100

2          a          11               200

3          a          12               300

1          b          16              

2          b          17              

3          b          18              

1          c          10

2          c          8

3         .c          11

I need to regress firms' a,b,c....returns on commodityret.So,do i paste commodity returns  for each firm on the commodity ret column?

If anybody can suggest the solution for Stata too,it is fine.        

1 REPLY 1
PGStats
Opal | Level 21

Assemble the data properly in a new table and call proc reg, BY firm. You'll get a separate regression for each firm :

data have;
infile datalines  missover;
input date     firm $      firmret     commodityret;
datalines;
1          a          10               100
2          a          11               200
3          a          12               300
1          b          16              
2          b          17              
3          b          18              
1          c          10
2          c          8
3          c          11
;

proc sql;
create table want as
select a.date, a.firm, a.firmret, b.commodityret
from have as a inner join have as b on a.date=b.date
where b.commodityret is not missing
order by a.firm, a.date;

quit;

proc reg data=want;
by firm;
model firmret = commodityret;
run;

PG

PG

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!

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