This gem installs a CLI program, sas2yaml which will (attempt) to read in a SAS input statement and turn it into a YAML file with the name of each variable along with its position in a fixed-width file, length, and type (assuming that information is available).

This gem was developed in order to decipher the fixed-width file structure of SEER Medicare SAS input statement files and works (fairly) well in processing those files. Your mileage almost certainly will vary.


Add this line to your application's Gemfile:

gem 'sas2yaml'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sas2yaml


sas2yaml ...

For each file listed, a lot of output will hit your screen, the program will hopefully not bomb out, and you'll end up with files named "file1.yml" and "file2.yml" (from the example above).


After checking out the repo, run bin/setup to install dependencies. Then, run rake false to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to


  • Outcomes Insights, Inc.
    • Many thanks for allowing me to release a portion of my work as Open Source Software!
  • Ruby
    • For being such an awesome language that it can pretend to be another (and much more awful) language cough SAS cough.


Bug reports and pull requests are welcome on GitHub at[USERNAME]/sas2yaml.