DATA Step, Macro, Functions and more

How to replace binary Number to 9

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

How to replace binary Number to 9

Hi 

 

My data set values are 

 

Numbers

1101

1001

0000

1000

0101

1010

And i want to replace the '0' with 3 and '1' with 2 .

 

How can we do that?

 

Thanks in advance.


Accepted Solutions
Solution
‎02-18-2018 02:17 AM
Super User
Posts: 10,570

Re: How to replace binary Number to 9

Posted in reply to neha_gupta

Convert to character with the put() function, use the translate() function to do the replacements, and convert back to numeric by using the input() function.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code

View solution in original post


All Replies
Solution
‎02-18-2018 02:17 AM
Super User
Posts: 10,570

Re: How to replace binary Number to 9

Posted in reply to neha_gupta

Convert to character with the put() function, use the translate() function to do the replacements, and convert back to numeric by using the input() function.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Occasional Contributor
Posts: 6

Re: How to replace binary Number to 9

Posted in reply to KurtBremser

Thanks mate,

 

Yes Its working fine.

☑ This topic is solved.

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

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