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;
Print out a few values for your date variables and see what they look like.
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.
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;
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;
how should i change the entire code to change my dsltdt format?
thanks a lot.
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?
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.