BookmarkSubscribeRSS Feed
Shmuel
Garnet | Level 18

Maybe there are some economical or statistical procedures that I'm not familiar with.

 

You can use the same logic as in computing the maxATQ in order to calculate the standard deviation

using its formula which I dont remeber exactly, that is something like:

- retain  sum_x - sum of variable  x

             sum_sqr_x - sum the squares of variable x

- then compute the STD using those sums retained and _N_ as cumulative number of observations

 

If you have one observation per qurter then just output each with the last computed values.

if you want comulative per whole years - output it on last.year - as in my post for maxATQ.

mkeintz
PROC Star

For each GVKEY you want maximum ATQ for the entire history of the company through the current DATADATE.  Since you are using ATQ, you must be using Compustat quarterly data, correct?

 

Your data is probably already sorted by gvkey/datadate.  If so, then

data want;
  set practice;
  by gvkey datadate;
  retain max_atq;
  if first.gvkey then max_atq=atq;
  else max_atq=max(max_atq,atq);
run;

I use "by gvkey datadate", even though I only need "by gvkey".  I threw in the datadate variable just to obligate SAS to report if data are out of order. 

 

For almost all of your results, the DATADATEs within a gvkey will be separated by exactly 3 months, based on whatever month the company uses to end its fiscal year.  HOWEVER, you can sometimes get shorter intervals, when a company changes its fiscal year.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
Astounding
PROC Star

The mean can be calculated by keeping track of the sum and N, accumulating as you go.  In similar fashion, standard deviation can be written as a function of N, sum, and sum of squared values.  If you accumulate all three pieces, you can use the same approach and calculate standard deviation at each point along the way.

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 17 replies
  • 1662 views
  • 3 likes
  • 6 in conversation