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

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

03-22-2017 05:08 PM

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

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

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

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

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

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

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.