Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Convert all variables into lowercase letters across data files

    Hi all,

    I am currently replicating a paper where the code was provided by the author.

    Yet, one problem with the code is that the var CHILDID is in upper case letters in the original data (comprising several data files). The code now sometimes renames it into lower case, and sometimes not.

    This yields the problem that it renames CHILDID to childid in the open file, but then tries to

    Code:
    merge childid using $rawr2oc\inchildquest12yrold.dta
    and obviously, in the using file, CHILDID is still in upper case letters.

    To get over this, I would like to change the data, i.e. change all variables, in all the files, across the folders, into lower case letters.

    Is there a smart way to do so? Or would you suggest another solution for the above-stated problem?

    Thanks a lot!

  • #2
    You can run the following code after opening each file.

    Code:
    foreach var of varlist *{
         rename `var' `=lower("`var'")'
    }

    Comment


    • #3
      Code:
      ren *, lower

      Comment

      Working...
      X