DATA Step, Macro, Functions and more

How to skip a month

Accepted Solution Solved
Reply
Contributor ZZB
Contributor
Posts: 34
Accepted Solution

How to skip a month

Hi all,

proc sql;

create table umd

as select distinct a.permno, a.date, a.prc, exp(sum(log(1+b.ret)))-1 as cum_return

from crspmom6(keep=permno date) as a, crspmom6 as b

where a.permno=b.permno and 0<=intck('month', b.date, a.date)<&J

group by a.permno, a.date

having count(b.ret)=&J;

quit;

How to change red words to skip one month, that is, skip the month between time t and t-1?


Accepted Solutions
Solution
‎03-06-2014 04:52 PM
Respected Advisor
Posts: 4,641

Re: How to skip a month

The two uses of &J do not seem to be related. The first refers to a number of months, the second, to a number of records...

WHERE condition only: Remove the "=" sign from the condition to exclude the current month and add a "=" sign before &J to include the Jth month..

HAVING condition has no apparent relation with your question...

PG

PG

View solution in original post


All Replies
Super User
Posts: 17,771

Re: How to skip a month

Not 100% sure what you want, because the question isn't clear and how you're incrementing &J isn't presented.

0<=intck('month', b.date, a.date)<&J+1?


Solution
‎03-06-2014 04:52 PM
Respected Advisor
Posts: 4,641

Re: How to skip a month

The two uses of &J do not seem to be related. The first refers to a number of months, the second, to a number of records...

WHERE condition only: Remove the "=" sign from the condition to exclude the current month and add a "=" sign before &J to include the Jth month..

HAVING condition has no apparent relation with your question...

PG

PG
Contributor ZZB
Contributor
Posts: 34

Re: How to skip a month

Thanks! It works.

In my case, '=' should not be added before &J, so in the HAVING condition, count should be &J-1

☑ This topic is SOLVED.

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

Discussion stats
  • 3 replies
  • 233 views
  • 0 likes
  • 3 in conversation