BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
dimuly0
Fluorite | Level 6

Dear community,

 

I am a fairly unexperienced SAS user and want to know the following since I cannot figure it out on myself.

 

Assume I have a huge dataset containing time series of multiple companies' earnings and cash flows.

The number of companies is around 20000 and there is data for 3-10 consecutive years for every company. 

Now I need to calculate the "Smoothness of earnings" measured by std(earnings) / std(cash flows) preferably for every company so that I can extract percentiles and the mean of all companies' smoothness values.

 

Is there a way to create a new table containing above mentioned information?

Perhaps some sort of listed standard deviations for earnings and cash flows regarding every company ID?

 

I assume there might be a way using proc sql, but I don't know the exact code to use, maybe you do 🙂

 

Any help will be highly appreciated, thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

That's helpful.

 

Something like this will calculate the standard deviations you want.

 

proc summary data=have nway; 
   class gvkey;
   var ib oancf;
   output out=_stats_ stddev=ib_s oancf_s;
run;

Then you can do the division in a subsequent data step.

 

data want;
    set _stats_;
    smoothness = ib_s/oancf_s;
run;
--
Paige Miller

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

Show us a small portion of this table of data.

--
Paige Miller
dimuly0
Fluorite | Level 6

Sure, here you go. I hope you can see the pdf

gvkey = indicates the individual company ID

ib = earnings before extraordinary items

oancf = operating cash flow

dimuly0
Fluorite | Level 6

Sure, here you go.

gvkey = Unique Company ID

ib = earnings before extraordinary items

oancf = cash flow

 

Beob.      gvkey fyear          ib              oancf

0010031987-0.5250-0.9870-0.5250
0010031988-7.8380-2.1000-7.8380
0010031989-2.5540-0.0320-2.5540
001004201372.9000139.800019.7000
0010042014-54.5000-43.0000-67.4000
001004201540.500032.100045.5000
001004201650.200021.800052.0000
001004201773.700064.300073.7000
00100919881.26601.65401.2660
00100919891.31702.22601.3170
00100919901.43102.07501.4310
00100919910.85703.37900.8570
00100919922.38806.02402.3880
00100919933.36203.44703.3620
00100919944.52301.92504.5230
0010102001145.7000114.200072.0000
001010200279.7000165.300077.3000
0010111991-1.4480-0.2430-1.8110
0010111992-2.1530-0.9410-2.1560
0010111993-3.1580-0.8170-3.1580
0010111994-9.19802.7190-9.1980
0010121988-0.18101.8660-0.1810
00101219890.91702.73500.9170
001013200431.30003.100029.0000
001013200585.500058.600096.0000
001013200694.200087.100093.3000
0010132007113.3000141.8000123.5000
0010132008-44.4000175.6000-39.4000
PaigeMiller
Diamond | Level 26

That's helpful.

 

Something like this will calculate the standard deviations you want.

 

proc summary data=have nway; 
   class gvkey;
   var ib oancf;
   output out=_stats_ stddev=ib_s oancf_s;
run;

Then you can do the division in a subsequent data step.

 

data want;
    set _stats_;
    smoothness = ib_s/oancf_s;
run;
--
Paige Miller
dimuly0
Fluorite | Level 6
The code worked perfectly.

Thank you very much!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 5 replies
  • 684 views
  • 1 like
  • 2 in conversation