BeOptimized - SAS to Python


Since couple of years, we see more and more companies eager to convert their SAS processes into Python.
At BeOptimized, we love both programming languages and can help you in that translation process.

Like it's not an easy task to convert French to English, it's not that easy to pass from SAS to Python because both languages are unique and work differently. Moreover, if you make a translation error when you convert French to English, you can always understand the meaning of the sentence because, placed into the context, human brain will interpret it correctly. Could we say the same when you convert a SAS code to Python? Certainly not because computers are not human brain and the translation process must be 100% equal not 99%.

Like butterfly effect, a small change in the code can have huge impact at the end... So you need a perfect understanding of the SAS code for this exercise, this is why BeOptimized could help you better than another.




  • +15y of experience with SAS code
  • Fully SAS certified expert in Base SAS & SAS advanced & SAS Viya
  • Strong Python knowledge with PCEP and PCAP certifications
  • Step by step approach: SAS codes and Python codes are run in parallel to make sure results are the same
  • Use SASpy python package to access historical SAS datasets
  • Possibility to be coached on how to convert SAS code to Python


For now, the service is limited to pure Base SAS code to Python:
  • We do not convert SAS Metadata nor Data Integration Jobs / DataFlux
  • We are focus on the SAS code only, not on the graphics or reports
  • We do not convert statistical procedures of the SAS/STAT module nor SAS/OR module
  • A valid SAS licence must be in place on site in order to run jobs in parallel

SAS and Python

Not all the SAS users want to use Python... Did you know that you could develop Python script to access SAS data and continue to use your SAS Software?
If you are still in SAS9, you can run both SAS and Python programs in the same environment using a SASpy package developed by SAS. It allows flexibility to transfer data between Pandas Dataframe and SAS Dataset. Imagine a situation when you have data in pandas dataframe and you wish to run SAS statistical procedure on the same without switching between SAS and Python environment.
If you are in the latest SAS version, the SAS Viya; you can use Python in various ways: from your Python environment or directly in the user interface.

    • The SAS Scripting Wrapper for Analytics Transfer ( SWAT ) package is a Python interface to SAS Cloud Analytic Services (CAS). Using SWAT, you can execute workflows of CAS analytic actions, then pull down the summarized data to further process on the client side in Python, or to merge with data from other sources using familiar Pandas data structures.
    • With the October 2021 release of SAS Viya, SAS introduced the Python Code Editor . Data Scientists and Python programmers can now code, execute and schedule Python scripts from within the SAS code editor interface (SAS Studio) or add Python steps to a SAS Flow quickly and intuitively.

Service Description

If you really want to migrate your SAS code into Python, BeOptimized can help you. At BeOptimized, we work with Agile methodology where each strory represent a group of SAS code. After conversion, SAS codes are run in parallel with Python code and validated by business. The sprints can only be closed by business. We work basically like this:
  • An analysis is made on your SAS environment to list all the SAS codes in place. Then we group the SAS codes into stories :
    • We estimate the complexity of the codes based on criteria such as the size, the number of Data Steps or Proc SQL, the Data Step size, the presence of macro, the presence of specific SAS statements (retain, first, last, infile...)
    • We use this estimation in order to create the stories/sprint and put them all into the backlog together with the Scrum Master.
  • When the sprint start:
    • Data are loaded into Python: if the data are coming from SAS7BDAT we import them using SASPy to limit dependancy,
    • SAS code is then converted into Python,
    • Result is compared with SAS results and discussed with business who can decide to validate or not the sprint
    • We continue with the next sprint.
    • When all the sprints are done, we come back to these where we used SASpy and adapt them so that their input corresponds to the output of an another sprint.
  • When all SAS codes of a story are done, it's important to run them in production and in parallel with existing SAS jobs. This ensure to have exactly same performance and behavior with real data.
In order to optimize the knowledge transfer, individual coaching session can be organized during the project realization.
You have a question? Please don't hesitate to contact us for more information.
Ok, It's too good to be true... converting a SAS code to Python is not possible... Why not? Let's make a POC !
  • Send us a SAS code of Max 200 lines (the code must run in our local environment)
  • Send us the DataSets used in that code (please make some anonymisation before)
  • Be patient for couple of days
  • We will send you back the Python code corresponding to your SAS code.

This site uses cookies. .

By continuing to browse the site you are agreeing to our use of cookies. Review our cookies information for more details.