BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ZZB
Obsidian | Level 7 ZZB
Obsidian | Level 7

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?

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

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

3 REPLIES 3
Reeza
Super User

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?


PGStats
Opal | Level 21

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
ZZB
Obsidian | Level 7 ZZB
Obsidian | Level 7

Thanks! It works.

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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