BookmarkSubscribeRSS Feed
Daniel1027
Obsidian | Level 7

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;

12 REPLIES 12
Astounding
PROC Star

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

Daniel1027
Obsidian | Level 7
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.
Astounding
PROC Star

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.

Daniel1027
Obsidian | Level 7
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.

Astounding
PROC Star

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;

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


ballardw
Super User

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;
Daniel1027
Obsidian | Level 7
dlstdt is numeric and format is:YYMMDDN8.
Daniel1027
Obsidian | Level 7
i know, it is a silly question. but how do i drop x and take y as a main afterward?
Daniel1027
Obsidian | Level 7

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

 

thanks a lot.Smiley Happy

Astounding
PROC Star

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?

Daniel1027
Obsidian | Level 7
dlstdt is the date .....

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
  • 12 replies
  • 2403 views
  • 0 likes
  • 3 in conversation