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!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.