Dear all,
how can I compare new_variable with the old_variable and show whether they have been changed( create a notification variable, say '1' if the new_variable is different from the old_variable, say '0' if both variables are the same.) The variables are different when they are the same word but different case.
for example, I expect to get the following result,
old_variable new_variable notification
apple Apple 1
juice juice 0
Original Original 0
mango nango 1
data have;
length
old_variable $20
new_variable $20 ;
input
old_variable
new_variable ;
cards;
apple Apple
juice juice
Original Original
mango nango
;
run;
Could you please give me some suggestions about this?
thanks in advance
A simple comparison between the variables should do.
data have;
length
old_variable $20
new_variable $20;
input
old_variable
new_variable;
change_flag= (old_variable ne new_variable);
cards;
apple Apple
juice juice
Original Original
mango nango
;
run;
What below line does:
change_flag= (old_variable ne new_variable);
old_variable ne new_variable -
Expression to compare the content in the two variables. The expression returns 1 (TRUE) if there is a difference and 0 (FALSE) if there is no difference
change_flag=
Variable to assign the result to from the result of the expression to the right of the equal sign.
A simple comparison between the variables should do.
data have;
length
old_variable $20
new_variable $20;
input
old_variable
new_variable;
change_flag= (old_variable ne new_variable);
cards;
apple Apple
juice juice
Original Original
mango nango
;
run;
What below line does:
change_flag= (old_variable ne new_variable);
old_variable ne new_variable -
Expression to compare the content in the two variables. The expression returns 1 (TRUE) if there is a difference and 0 (FALSE) if there is no difference
change_flag=
Variable to assign the result to from the result of the expression to the right of the equal sign.
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.