BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Sir_Highbury
Quartz | Level 8

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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.

View solution in original post

5 REPLIES 5
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

Sir_Highbury
Quartz | Level 8

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. 😞

 

Reeza
Super User

@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. 

Sir_Highbury
Quartz | Level 8

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

Kurt_Bremser
Super User

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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

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
  • 5 replies
  • 958 views
  • 2 likes
  • 4 in conversation