DATA Step, Macro, Functions and more

Hi! Does anybody have a clue why this error appeared?

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

Hi! Does anybody have a clue why this error appeared?

Hello!

This is my macro code:

%macro printz(patient);

    proc print data = PT;

        where patient = "&patient";

        var patient AGE_DERIVED_FUL AGE_DERIVED_UNIT_FUL LstChg_Ts;

    run;

%mend printz;

%printz(10011001)

After submission, I got the error message:

ERROR: WHERE clause operator requires compatible variables.

Can I get some help?


Accepted Solutions
Solution
‎02-02-2015 02:24 PM
Super User
Posts: 3,102

Re: Hi! Does anybody have a clue why this error appeared?

Most likely patient is a numeric variable so your WHERE clause needs a compatible value. Remove the quotes to correct your error: where patient = &patient;

View solution in original post


All Replies
Solution
‎02-02-2015 02:24 PM
Super User
Posts: 3,102

Re: Hi! Does anybody have a clue why this error appeared?

Most likely patient is a numeric variable so your WHERE clause needs a compatible value. Remove the quotes to correct your error: where patient = &patient;

Occasional Contributor
Posts: 5

Re: Hi! Does anybody have a clue why this error appeared?

Thank you! It works!

Occasional Contributor
Posts: 6

Re: Hi! Does anybody have a clue why this error appeared?

try this

%macro printz(patient=);

    proc print data = PT;

        where patient = "&patient";

        var patient AGE_DERIVED_FUL AGE_DERIVED_UNIT_FUL LstChg_Ts;

    run;

%mend printz;

%printz(patient=10011001)

Occasional Contributor
Posts: 5

Re: Hi! Does anybody have a clue why this error appeared?

Thanks! Yes, patient is a numeric variable and after the correction it works!

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 232 views
  • 3 likes
  • 3 in conversation