Dear experts,
I have the following variable: PAID_YYYYMM (length 25, format $25., informat $25.)
I would like to filter the table using the following variable: %let date=201609;
To do it I am using the proc sql, stating the where as: PAID_YYYYMM='201609' but replacing the number with the variable date.
I tried the following matching but I get always an empty data set:
where PAID_YYYYMM='&date.' ;quit;
/* where PUT(PAID_YYYYMM, $10.)="'&date.'" ;quit; */
/* where PUT(PAID_YYYYMM, $10.)='&date.' ;quit; */
What is wrong in the logic used?
Thanks in advance for the support.
Best regards,
SH
If you really used single quotes around the macro variable, why are you surprised?
Single quotes prevent the resolution of macro triggers. Use double quotes. Only double quotes.
Well, take a look at what is generated from the macro:
where PAID_YYYYMM='&date.' ;quit;
If
%let date='201609';
Then:
where PAID_YYYYMM='201609';
Are there recrod in your read in dataset where paid_yyyymm='201609'?
Its very hard to tell you what is wrong with the logic without seeing the data it is operating on - post some test data (in the form of a datastep) will make it easier to debug.
Dear RW9,
thanks for your support, the data is specified as it follows: %let date=201609 and I cannot change it (e.g. '201609'). I cannot share the data set I am working on. 😞
@Sir_Highbury wrote:
I cannot share the data set I am working on. 😞
You don't need to share the data set you're working on. You need to provide sample data, which can be fake, that is enough to replicate your problem. It just needs to be similar enough so we can understand your issue. You'll get better and faster answers. if you do this.
It was a clear question and I got the issue solved without losing time to create the fake error. Thanks for your effort but please try to answer if you can. The decision about the question and if and how attach data is mine, if you disagree feel free to ignore the topic. 😉
Have a nice day, SH
If you really used single quotes around the macro variable, why are you surprised?
Single quotes prevent the resolution of macro triggers. Use double quotes. Only double quotes.
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.