Hi There,
In below example, I would like to get missing ID values which is not matched with my assigned value in macro variable. I know I can perform this task as I did in my Query2 to get correct output, but I don't understand about what's wrong in my Query1.
Can someone explain me why query1 in my below piece of code is not giving desired output?
/****************************************************************************************/
data ID_Table;
input ID $10.;
cards;
1000000001
1000000002
1000000003
;run;
%let IDN1 = 1000000001;
%let IDN2 = 1000000002;
/*Query1*/
data Missing_ID_Wrong_Output;
set ID_Table;
IDN1=input(&IDN1.,best12.);
IDN2=input(&IDN2.,best12.);
if (ID ne IDN1 OR ID ne IDN2) then output;
keep ID;
run;
proc print data=Missing_ID_Wrong_Output noobs;run;
/*
ID
1000000001
1000000002
1000000003
*/
/*Query2*/
data Missing_ID_Correct_Output;
set ID_Table;
if ID not in (&IDN1., &IDN2.) then output;
run;
proc print data=Missing_ID_Correct_Output noobs;run;
/*
ID
1000000003
*/
/****************************************************************************************/
If fix below, you can get correct output.
if (ID ne IDN1 AND ID ne IDN2) then output;
Thanks folks for quick respond with perfect solution!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.