DATA Step, Macro, Functions and more

Adding Variables

Accepted Solution Solved
Reply
Contributor
Posts: 32
Accepted Solution

Adding Variables

I have two address variables in my dataset and am trying to create another variable that indicates whether the two addresses match or not (1 indicating a match and 0 indicating not a match). The SAS book I am using appears to only instruct on how to create variables using mathematical functions. Can I create a variable using an if-then statement? How would I code that input?


Accepted Solutions
Solution
‎01-16-2018 01:25 PM
Respected Advisor
Posts: 2,807

Re: Adding Variables

Posted in reply to andrewfau
if variable1=variable2 then newvariable=1; else newvariable=0;
--
Paige Miller

View solution in original post


All Replies
Solution
‎01-16-2018 01:25 PM
Respected Advisor
Posts: 2,807

Re: Adding Variables

Posted in reply to andrewfau
if variable1=variable2 then newvariable=1; else newvariable=0;
--
Paige Miller
Contributor
Posts: 32

Re: Adding Variables

Posted in reply to PaigeMiller

Thanks! I was close.

☑ This topic is solved.

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

Discussion stats
  • 2 replies
  • 104 views
  • 0 likes
  • 2 in conversation