Forecasting using SAS Forecast Server, SAS/ETS, and more

Amihud (2002) Liquidity Measure

Accepted Solution Solved
Reply
Contributor
Posts: 58
Accepted Solution

Amihud (2002) Liquidity Measure

Hello Folks

I am trying to implement the above-mentioned measure.  It is very straightforward measure. 
Liquidity od stock month 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
Super User
Posts: 5,082

Re: Amihud (2002) Liquidity Measure

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.)

View solution in original post


All Replies
Contributor
Posts: 58

Re: Amihud (2002) Liquidity Measure

Super User
Posts: 17,819

Re: Amihud (2002) Liquidity Measure

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.

Contributor
Posts: 58

Re: Amihud (2002) Liquidity Measure

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

SAS Employee
Posts: 416

Re: Amihud (2002) Liquidity Measure

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

Contributor
Posts: 58

Re: Amihud (2002) Liquidity Measure

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
Super User
Posts: 5,082

Re: Amihud (2002) Liquidity Measure

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.)

Contributor
Posts: 58

Re: Amihud (2002) Liquidity Measure

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. 

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 551 views
  • 1 like
  • 4 in conversation