SAS to CSV - The Easy Way
October 15, 2020•157 words
Since I don't do much of my work in SAS, but some of the data I receive is in SAS format, I've created a SAS script that can be run from the terminal to convert a .sas7bdat
file into an ordinary .csv
file (optionally compressed to .csv.gz
). There is also a Python script to run batch conversions of many SAS data files in parallel. This requires both Python and SAS to be installed.
The SAS and Python scripts can be found here.
Single file conversion
Make sure SAS is on the path and from the root directory run:
sas sas_to_csv.sas ^
-set in "<absolute_path>/<filename>.sas7bdat" ^
-set out "<absolute_path>/<filename>.csv"
Batch conversion
- Make sure SAS is on the
path
- Put the files you want to convert in the
data-sas
folder Run the Python script from the root directory:
python convert_all_files.py
Find the exported CSV files in the
data-csv
folder