Announcement

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

  • use substr but only for a modality of a variable

    Hello,
    I'm starting to use stata and i wonder if there is a way to use the substr function or an other function in order to keep the first two letters of a modality of a variable but not to all the data. For example, if there's a variable "prescriber" with a lot of differents modality (Dr A, Dr B, hospital A, hospital B...) is it possible to cut the data in order to have : Dr, Dr, hospital, hospital... ?
    Thanks for your help

  • #2

    Code:
    gen wanted = word(whatever, 1)
    would work with your examples.

    Comment

    Working...
    X