Announcement

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

  • Help with old code using renvars and presub

    Hi all:

    Non-Stata user here trying to work through translating some Stata code that as left behind by a former team member into R code. For the most part, the syntax makes intuitive sense to me, but I wanted to double-check my interpretation of a short variable renaming piece where renvars was used.

    Here's an example that parallels the actual statements and the variable names and other arguments.

    frame new_frame {
    keep if event=="event_1"
    keep pid language event date///
    p_sc_site ///
    p_xvar1 p_xvar2 p_xvar3

    rename p_sc_site site
    renvars p_*, presub(p_ )
    }


    After a few Google searches and searching here, my best guess about this renvars statement is that the presub(p_ ) [(p underscore space)] specification is telling renvars to remove the p_ [p underscore] prefix from the beginning of the p_xvar variable names.

    Am I on the right track, or is something else going on here?

    Thanks so much!
    Last edited by Michael Todd; 23 Feb 2024, 14:29.

  • #2
    I have not used renvars (from SJ 5-4) in a while but I believe you are right.

    In "modern" Stata (since 2011), you would write that as

    Code:
    rename p_* *

    Comment


    • #3
      Correct. renvars had its day in the sun — in fact about a decade in the sun — but once rename was rewritten it became obsolete, otiose, superfluous, unnecessary, redundant and utterly unloved.

      Comment

      Working...
      X