turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Forecasting
- /
- Amihud (2002) Liquidity Measure

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-22-2017 04:56 PM

Hello Folks

I am trying to implement the above-mentioned measure. It is very straightforward measure.

Liquidity od stock *i *__month __*t *day d is;

=(1/number of valid observations in month) * (sum[abs(return(i, t, d)/volume(i,t,d))]

further, no of valid observation in a month must be more than 10.

my date format is yyyymmdd and all my variables are daily based. I am having difficulty in calculating no of valid days in a month.

kindly give me some code which can calculate no of valid days in a month.

so far i tried these codes

data illiquid;

set crspd;

Liquidity=abs(returns)/abs(volume); run;

I have problem in calculating no of valid days in a month.

Need your help please .

Thanks in advance

Accepted Solutions

Solution

03-23-2017
02:23 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to raqthesolid

03-22-2017 05:28 PM

Because you have to count across multiple observations, you will need to take a few steps. This is only one approach ... SAS usually provides alternatives that also work.

(1) Add YEAR and MONTH to the data set.

This sample code assumes that your dates are SAS dates. If they are not, you will need to do this step differently.

data with_month;

set crspd;

year = year(date);

month =month(date);

run;

(2) Count "valid" dates per symbol, per month.

Since you haven't provided a definition of "valid", I will assume it means dates where volume > 0.

proc freq data=with_month;

tables symbol * year * month / noprint out=monthly_counts (drop=percent);

where volume > 0;

run;

(3) Sort your original data:

proc sort data=with_month;

by symbol year month;

run;

(4) Merge in the number of valid days:

data want;

merge with_month monthly_counts (rename=(count=n_valid_days) in=have_counts);

by symbol year month;

if have_counts=0 then n_valid_days=0;

run;

That at least gets you N_VALID_DAYS on each observation to work with. Presumably, you know where to go from there. (Or perhaps you need to post a new question at that point.)

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to raqthesolid

03-22-2017 05:08 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to raqthesolid

03-22-2017 05:18 PM

Please post some sample data, expected output and your current not working code as well so we know where to start off. There are probably multiple approaches and if you're close there's no point in starting off from scratch.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

03-23-2017 02:28 AM

Thanks for replying. i got my issue fixed. i will post here my full codes so that anyone can use in future.

Good day

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to raqthesolid

03-22-2017 05:23 PM

Hello -

If you have access to SAS/ETS software you may want to use the TIMESERIES procedure - in particular the OUTSUM data set should be of interest.

Example:

proc timeseries data=sashelp.citiday outsum=work.outsum out=_null_;

id date interval=day accumulate=total;

var SNYDJCM;

run;

Thanks,

Udo

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to udo_sas

03-23-2017 02:27 AM

thank you very much for replying although I did not work for me. the codes provided by someone else did perfectly what I wanted.

still thank you I think I was not able to communicate my issue properly. I will post the full codes as soon I arrange them with proper notes.

Have a good day

Solution

03-23-2017
02:23 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to raqthesolid

03-22-2017 05:28 PM

Because you have to count across multiple observations, you will need to take a few steps. This is only one approach ... SAS usually provides alternatives that also work.

(1) Add YEAR and MONTH to the data set.

This sample code assumes that your dates are SAS dates. If they are not, you will need to do this step differently.

data with_month;

set crspd;

year = year(date);

month =month(date);

run;

(2) Count "valid" dates per symbol, per month.

Since you haven't provided a definition of "valid", I will assume it means dates where volume > 0.

proc freq data=with_month;

tables symbol * year * month / noprint out=monthly_counts (drop=percent);

where volume > 0;

run;

(3) Sort your original data:

proc sort data=with_month;

by symbol year month;

run;

(4) Merge in the number of valid days:

data want;

merge with_month monthly_counts (rename=(count=n_valid_days) in=have_counts);

by symbol year month;

if have_counts=0 then n_valid_days=0;

run;

That at least gets you N_VALID_DAYS on each observation to work with. Presumably, you know where to go from there. (Or perhaps you need to post a new question at that point.)

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Astounding

03-23-2017 02:25 AM

Thank you very much it worked for me and I am able to calculate the full Amihud(2002) measure I will post here the full codes if someone needs this to use in his/her research.

good Job and thank you again.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to raqthesolid

09-25-2017 11:45 PM

Hello Raqthesolid,

Can you please share the code ? .. will be appreciated.

Thanks!

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to trest_luam

09-26-2017 03:36 AM

Hello there,

the following codes worked for me. i hope they will help you too.

***Calculating liquidity from Daily data.;

*liquidity calculation following Amihud (2002) conditions;

2) At least 10 trading days in a month

3) Using daily data to calculate monthly Liquidity;

data Dailyp;

set daily;

Trans_month = MDY(MONTH (Date),1, YEAR(Date)); run;

proc sort; by trans_month; run;

data dailypa (Drop=Vol);

set dailyp;

prc=abs(prc);

if vol <= 0 then delete; *(-99 Volume is used when there are missing values);

if prc=. then delete;

if vol=. then delete;

Dvol=prc*vol; run;

**(2) Count "valid" dates per firm, per month. I assumed it means dates where volume > 0.;

proc freq data=dailypa;

tables symbol * year * month / noprint out=monthly_counts (drop=percent);run;

data Monthly_counts1;

set monthly_counts;*run; **(at least 10 trading days for each stock in a month;

if COUNT<10 then delete; run;

data illiquid;

set dailypa;

if ret=0 then delete;

ratio=abs(ret)/Dvol; run;

proc sort data=illiquid; by symbol year month; run;

proc summary data=illiquid nway;

class symbol year month;

var ratio;

output out=summary_data (keep=symbol year month total_ratio) sum=total_ratio; run;

proc sort data=summary_data;

by symbol year month; run;

proc sort data=monthly_counts1; by symbol year month; run;

data illiquidd;

merge summary_data monthly_counts1; by symbol year month; if count<5 then delete; run;

data mydata.Liquidity(drop=ratio2 total_ratio count symbol);

set illiquidd;

ratio2=10**6 *total_ratio; *(this is just to show in better form);

ILLIQUIDITY=ratio2/COUNT;

permno=symbol;

run;

proc sort;

by ILLIQUIDITY; run;

proc means;

var illiquidity ; run;

Good luck. let me know if you stuck anywhere and if my presentation is not very helpful.

Regards

ABdul

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to raqthesolid

10-11-2017 03:49 PM

Thanks a bunch for your response Abdul.

I appreciate your help.

Best.

Trey

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to raqthesolid

a week ago

Hi Abdul

Thanks for sharing your codes. Trying to follow to obtain same measure but the section below is giving me errors.

**(2) Count "valid" dates per firm, per month. I assumed it means dates where volume > 0.;

proc freq data=dailypa;

tables symbol * year * month / noprint out=monthly_counts (drop=percent);run;

Did you create the year and month separately before running the codes as i have only date for each day.I did change the symbol =permno and was ok.

Thanks for the help in advance.regards.ejaa.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to EJAA

a week ago - last edited a week ago

Hello dear,

you can easily create year, month and day variables from your date. if your date is in sas date formate.

year = year(Date);

month = month(Date);

day = day(Date);

i did this because i have to calculated illiquidity on monthly basis from days. additionally i also wanted to see how many days are being used in each month. i require atlease 10 days in a month.

sorry for confusion among permno and symbol.. i originally used permno (USA data) and changed it for you. but few were left out. please assume permno, firmid or symbol as firmID .

hope this might help.

feel free to ask.

good day

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to raqthesolid

a week ago

Thanks very much for the explanation.I will effect the changes.However, I want to calculate daily amihud illiquidity measure and will you codes work for that as well?thanks

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to EJAA

a week ago

I did not do for Amihud (2002) and never saw it on daily as well. You can do it daily if you know some papers who did it. Otherwise other measures like spread, turnover etc might be more suitable on daily basis.