Export a SAS dataset to Stata with all variable names converted to lowercase

I use both SAS and Stata and often need to transfer data between the two. SAS is case-sensitive and Stata is not. I always prefer working with lowercase variable names in Stata. The following code is used to export a SAS dataset to Stata with all variables names converted to lowercase.

The macro I use is borrowed from Adrian’s work. Thanks Adrian.

A related post can be found here: http://kaichen.work/?p=1365.


This entry was posted in SAS. Bookmark the permalink.

3 Responses to Export a SAS dataset to Stata with all variable names converted to lowercase

  1. Alex Luong says:

    Hi Kai,
    I would suggest using “rename *, lower” in Stata.
    Adrian is actually a friend of mine and he is also using this now.

  2. Elisha says:

    Hello Kai,

    When I use proc export for .dta files, it automatically lowers the case for all variables. Is there a way to preserve the Upper or Proper case variable names? Thanks!

    • Marie says:

      I would like to know this, too!
      I am exporting a lot of large data sets from SAS to STATA. If I use STAT-transfer, it retains the case of the variables, but my company decided not to pay for STAT-transfer because proc export in SAS can do the job. Only that it can’t, because it translates all variable names to lower case.
      So if, say, 80 percent of appr. 2000 variables are uppercase, using rename *, upper in STATA works but still creates trouble for the remaining 20 percent. So ideally I would like to know if variable cases can be preserved in proc export. Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *