I think I’ve used IF-THEN-ELSE Statement or conditional coding in almost every analysis or program I have developed in the last 30 years. It is very useful in both preparing and cleaning data.

IF-THEN-ELSE is an integrated part of the data step in SAS. We don’t have an object for a data step in Python, but can step through the data frame in a similar way and use IF-ELIF-ELSE as it is called in Python.

So in this article, We will look at what we do in SAS and see how we can do the same kind of conditional coding in Python. I’ll also show you alternative ways of running IF-ELIF-ELSE statements.

#python #learning-to-code #data-analytics #data-science

How to use IF-THEN-ELSE in Python the way you work in SAS
2.65 GEEK