DATA Step, Macro, Functions and more

INTNX - problem

Reply
Contributor
Posts: 21

INTNX - problem

Hello everyone,

 

I was trying to implement this code, unfortunately sas does not recognize intnx. what should i do?

Best wishes,

Sincerely Daniel,

ROC SQL;
CREATE TABLE crsp_m2
AS SELECT A.*, B.dlret,
sum(1,ret)*sum(1,dlret)-1 as retadj "adjusted return for delisting",
abs(a.prc*a.shrout) as MEq 'Market Value of Equity'
FROM CRSP_M AS A LEFT JOIN tmp1.msedelist (where=(missing(dlret)=0 ) ) AS b
ON a.permno=b.permno AND
intnx('month',a.date,0,'E')=intnx('month',b.DLSTDT,0,'E')
ORDER BY date, permco, MEq;
QUIT;

Super User
Posts: 5,071

Re: INTNX - problem

Print out a few values for your date variables and see what they look like.

Contributor
Posts: 21

Re: INTNX - problem

the code works without implementing abs and intnx. i am okay with this code. but afterwards i thought, abs and intnx may cause new issue. because my final code is not working. intnx and abs are the reason why final code is not wokring for sure.
Super User
Posts: 5,071

Re: INTNX - problem

When you say "this code works" what does that mean?  It might run without error, but the output will certainly be different when you take out significant pieces of the program.

Contributor
Posts: 21

Re: INTNX - problem

i mean, this code works with some warnings. log shows :
LOG:
NOTE: Invalid (or missing) arguments to the ABS function have caused the function to return a
missing value.
NOTE: Invalid argument 2 to function INTNX. Missing values may be generated.

Super User
Posts: 5,071

Re: INTNX - problem

Unless you can explain the reason for a warning, it is dangerous to ignore it. 

 

Here is a program  you can try, to inspect one of the date variables.

 

options obs=5;

proc print data=tmp1.msedelist;

var dlstdt;

where dlstdt=.;

run;

proc print data=tmp1.msedelist;

var dlstdt;

where dlstdt > .;

run;

options obs=max;

Contributor
Posts: 21

Re: INTNX - problem

i am novice to sas and a student who is trying to learn sas individually. here is what i get :
Obs DLSTDT
1 19870611
2 20151231
3 20130215
4 19951215
5 19910711


Super User
Posts: 10,466

Re: INTNX - problem

SAS expects the values of a date variable in a specific format, namely the number of days since 1 jan 1960. Your DLSTDT​ variable looks to be a yyyymmdd value, which is not a SAS data value. Is your currnt DLSTDT​ character or numeric. You will need to create a date value and the approach varies depending on what type variable you currently have.

 

A brief example program;


data junk;
   x = input('19870611',yymmdd8.);
   y = intnx('month',x,1);
   format x y mmddyy10.;
run;

proc print; run;
Contributor
Posts: 21

Re: INTNX - problem

dlstdt is numeric and format is:YYMMDDN8.
Contributor
Posts: 21

Re: INTNX - problem

i know, it is a silly question. but how do i drop x and take y as a main afterward?
Contributor
Posts: 21

Re: INTNX - problem

how should i change the entire code to change my dsltdt format?

 

thanks a lot.Smiley Happy

Super User
Posts: 5,071

Re: INTNX - problem

Given what you found (the sample values you printed, plus knowing that your variable is numeric with a format of YYMMDDN8.), the DSLTDT variable is fine.

 

Are you able to get similar information for the other date variable named DATE?

Contributor
Posts: 21

Re: INTNX - problem

dlstdt is the date .....
Ask a Question
Discussion stats
  • 12 replies
  • 446 views
  • 0 likes
  • 3 in conversation