Reputation: 1
I am trying to create a flag that shows a 1, when a variable match_flg = total_match_flg
, otherwise return a 0.
When i run the following code
proc sql;
create table xxxxxxx as
select*,
CASE
when match_flg = total_match_flg then 1 else 0
end as keep_flg
quit;
it returns all 1 and am sure in the dataset that statement should false and return some 0
What am i doing wrong ?
Upvotes: 0
Views: 53
Reputation: 2640
Is it because you're not reading any data in with a from statement? I ran similar code (added a from) and it ran fine.
Edit: Including my test data;
data test;
do i = 1 to 10;
match_flag = i;
total_match_flag = 10-i;
output;
end;
drop i;
run;
proc sql;
create table x as
select *,
case
when match_flag = total_match_flag then 1 else 0
end as keep_flg
from test;
quit;
As a sidenote, case can be clumsy to use. Have a look at the IFC/IFN functions instead. http://www.lexjansen.com/wuss/2012/28.pdf
Upvotes: 2