Search code examples
sasfinance

aggregate daily total in sas


I'm looking to find the total daily market cap of a stock exchange. So far I have calculated daily market caps for each firm listed and now I'm calculating an aggregated market cap for the exchange.

The code I have used so far is:

proc means data=index.mrk_cap sum; var MarketCap; by date; output out=Tot_MKT; run;

This generates daily market caps but only in a project form output and I would like my data to be usable in a data set. Any modifications that would let me create daily market caps would be great.


Solution

  • You need to put the sum keyword on the output statement.

    output out=Tot_MKT sum(MarketCap)=mktCap_Sum;
    

    Output doesn't by default create any variables; you have to specify exactly what you want output to the dataset. There are a wealth of papers on the subject available (search http://lexjansen.com/ or http://sas.com/ for examples).