## Description

ascol converts daily data of asset prices or returns to weekly, monthly, quarterly, or yearly frequencies. When converting asset prices to a lower frequency, ascol selects the last price in the given period. For converting asset returns, ascol offers two possibilities – either to sum the daily returns or find products of the daily returns. The first choice is used with daily log returns while the second is used with daily simple returns (Detailed discussion is given below). ascol requires that the existing data has a time variable that tracks daily dates. If the data is already *tsset* or *xtset*, ascol will

automatically pick the time and panel variables from the previous tsset or xtset declarations. In case the data is not already set for time or panel

dimensions, then the time variable has to be set by using the option *timevar(**varname**)*.

## How to Install it

ascol can be installed from SSC by typing the following line of code in the Stata command window

ssc install ascol

## Options

ascol has the following options.

## 1. returns

This option can be entered as returns(simple) or returns(log). If we wish to convert daily returns to a lower frequency we shall use this option. This option can be used with two variations: *simple* returns and *log *returns. For detailed discussion, examples, and comparisons of simple and log returns, please visit this

### 1.1 returns(simple)

If daily returns have already been calculated with the following formula;

simple ri = ( Price[i] - Price[i-1] ) / Price[i-1] ... (Eq. 1)

Then the appropriate method to convert the returns to *n-period* cumulative returns would be;

Cumulative n-period simple returns = (1+simple_r1) * (1+simple_r2) *(1+simple_r3) * (1+simple_rn) - 1 ... (Eq. 2)

By invoking option returns(simple), ascol applies Eq. 2 to find n-period cumulative returns.

### 1.2 returns(log)

If daily returns have already been calculated with the following formula;

log_ri = ln(Price[i] / Price[i-1]) ... (Eq. 3)

Then the appropriate method to convert the returns to *n-period*s cumulative returns would be to just sum the daily returns. By invoking option *returns(log)*, ascol sums the daily returns to find *n-period*s cumulative returns. Therefore, users must exercise care in selecting the appropriate option in converting daily returns to n-period cumulative

## 2. prices

If the data in memory are asset prices, we shall use the option *prices.* Please note that option *return* and *prices* cannot be combined together. To

collapse prices to the desired frequency, the program finds the last traded prices of the period.

## 3. Frequency Options

ascol has the following options for data conversion:

**toweek **converts from daily to weekly frequency

**tomonth**** **converts from daily to monthly frequency

**toquarter**** **converts from daily to quarterly frequency

**toyear** converts from daily to yearly frequency

## 4. timevar(varname) and panelvar(varname)

ascol needs a variable that tracks daily dates. If the data is already *tsset,* ascol will automatically pick the time variable. Therefore, there will be no need to use the opt*ion timeva*r(). Similarly, if the data is alr*eady x*tset, ascol will pick both the time and panel variables from the previous xtset

declarations. Again, there will be no need to use the options timevar() or *panelvar**()*. However, if the data has duplicates or has other reasons that do not allow the tsset or xtset declarations, then we shall have to inform ascol about the time and/or panel variables of the data set through options*timevar(**varname**) *and *panelvar**(**varname**).*

## 5. keep(all) or keep(vars)

When we convert data from daily to a lower-frequency such as weekly, monthly, etc., we end up with repeated values of the converted variable. We often just need one value of the variable per cross-sectional unit and time-period. Therefore, the repeated observations are not needed and should be dropped. This is what the Stata’s collapse command does. The default in ascol is to collapse the data to a lower frequency and delete all other variables except the

frequency and keep all the variables of the data set. Here is the summary:

** keep(all)** conversion happens without collapsing the data and without deleting other variables

** keep(vars)** conversion happens without deleting other variables; data collapses to a lower frequency

## 6. generate(newvar)

This is an optional option to specify the name of the new variable. If left blank, ascol will automatically name the new variable as *varname_frequency.*

## Example Data Set

Let us generate a dummy data set for our example. Copy the following and run from Stata do editor

clear

set obs 1000

gen date=date("1/1/2012" , "DMY")+_n

format %td date

tsset date

gen pr=10

replace pr=pr[_n-1]+uniform() if _n>1

gen simpleRi=(pr/l.pr)-1

gen logRi = ln(pr/l.pr)

save stocks, replace

**Example 1: From Daily to weekly – simple returns**

Suppose we have already generated daily simple returns using Equation 1, we shall convert them to weekly returns with:

use stocks, clear

ascol simpleRi, toweek returns(simple)

ascol is the program name, is the stock return variable in our data set,

**is the program option that tells Stata to convert daily data to**

toweek weekly frequency, and

*the returns(sim*ple) option tells Stata that

**our**s

l

**Example 2: From Daily to weekly – log returns**

Suppose we have already generated log returns using Equation 2, we shall convert them to weekly returns with:

use stocks, clear

ascol logRi, toweek returns(log)

ascol is the program name, **logRi***toweek***logRi*** *variable has log stock returns. Therefore ascol will just sum the returns within each week to find cumulative weekly returns. Please note that we did not use the option

**timevar(**

**varname***and*

**)**

**panelvar**

**(**

**varname***as our data is already tsset.*

**)****Example 3: From Daily to monthly – prices**

use stocks, clear

ascol pr, tomonth price

**Converting Data to Other Frequencies**

From daily to quarterly, option

ascol pr,toq price

From daily to yearly, option

ascol pr, toy price

**Example 4: Conversion without collapse – keep all observations and variables**

We shall use the option keep(all) to retain all variables and observations in the data set. After conversion, you can see that there are duplicate values of

the

use stocks, clear

ascol simpleRi , toweek returns(simple) keep(all)

**Example 5: Collapsing by time variables only – keep variables**

We shall use the *keep(vars)* to retain all variables while collapsing the data to a lower frequency. After conversion, you can see that there are no duplicate values of the

use stocks, clear

ascol simpleRi , toweek returns(simple) keep(vars)

## 1 Comment

## Ishaq

December 9, 2018at 5:55 pmGreat work sir……….