Hello team,
I have code below. I added tday to datasetp. It keeps saying that tday doesn't exist.
data combo2; tday = date(); format tday MMDDYY10.; set combine; where tday - someonedob <= 2; run;
Log:
ERROR: Variable tday is not on file WORK.COMB02.
Any tip is greatly appreciated?
Thanks,
Blue blue
Hello Paige,
It is acknowledged. I won't.
I understand that we can't create a variable in a data step and then put where clause on that variable on the same data step. Is this what meant by this?
"The WHERE statement applies to all data sets in the preceding SET, MERGE, MODIFY, or UPDATE statement, and variables that are used in the WHERE statement must appear in all of those data sets. You cannot use the WHERE statement with the POINT= option in the SET and MODIFY statements."
Regards,
Blue
When there is an error in the log, show us the ENTIRE log for this data step. Do not show us part of the log. Do not show us only the errors. (And please don't make us ask for this repeatedly).
The WHERE statement cannot be used like that. According to the documentation:
The WHERE statement applies to all data sets in the preceding SET, MERGE, MODIFY, or UPDATE statement, and variables that are used in the WHERE statement must appear in all of those data sets. You cannot use the WHERE statement with the POINT= option in the SET and MODIFY statements.
Your usage of WHERE does not meet the requirements stated. The variable TDAY is not a part of the variables in the preceding SET statement. So it can't be used like that.
However, if you replace WHERE with IF, then the code works.
Hello Paige,
It is acknowledged. I won't.
I understand that we can't create a variable in a data step and then put where clause on that variable on the same data step. Is this what meant by this?
"The WHERE statement applies to all data sets in the preceding SET, MERGE, MODIFY, or UPDATE statement, and variables that are used in the WHERE statement must appear in all of those data sets. You cannot use the WHERE statement with the POINT= option in the SET and MODIFY statements."
Regards,
Blue
The WHERE clause is applied as the data is read from the source dataset(s). So you cannot reference variables in the WHERE statement that do not exist in the source dataset(s) because they don't exist!
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.