Hello,
I was wondering if anyone could help me find a solution to this problem.
This is the code I'm trying to execute in SAS 9.3:
proc sql;
create table BE (drop=CUSIP PRC shrout) as
select a.*, b.*, b.me as size
from comp1 as a
LEFT JOIN msex2(drop=RET)as b
on a.cusip=b.cusip
where (a.fyear+1)=year(b.date)and month(b.date) = 6;
run;
And when I run it, I get:
NOTE: Invalid (or missing) arguments to the YEAR function have caused the
function to return a missing value.
NOTE: Invalid (or missing) arguments to the MONTH function have caused the
function to return a missing value.
I've checked the table, I did the summary listing all the available dates and also checked for the missing values. The DATE field in the table has no missing or invalid values.
I just can't figure out, why it's giving my this error,
Thank you in advance for anyone's input!
That's a toughie!
All I can think of is to run these two queries (syntax unchecked).
select min(date) as mindate, max(date) as maxdate from msex2;
These shoud be roughly between the range of -137727 and 6552447. If they are wildly out of that range, they are probably datetime variables or erroneous data.
And the other, which I think you've already run, is
select count(*) from msex2 where date is missing;
Good luck!
Tom
What variable type is date? And what format?
It is because you are doing a LEFT JOIN and so some of the results from the join that are passed to the WHERE clause might not have had any contribution from the right had table. Therefore the value of the DATE variable will be missing.
Why not just add the condition to the ON clause?
proc sql;
create table BE (drop=CUSIP PRC shrout) as
select a.*, b.*, b.me as size
from comp1 as a
LEFT JOIN msex2(drop=RET)as b
on a.cusip=b.cusip
and (a.fyear+1)=year(b.date)and month(b.date) = 6
;
quit;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.