Announcement

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

  • replacing several var values for a particular id

    Hello, a beginner here,

    I have a list of varnames and several IDs. Different ids needs replacing values in only several varnames of the whole lot from value 2 to value 1 (varnames not answered are left blank or coded differently). Different IDs need replacing values within different varnames, which complicates things. Doing it by the different varlist for each ID can be daunting. I would like to do it by a code that identifies which varname for the particular ID specified in the code has the answer 2 and replace the value to 1, ignoring other values.
    Can it be done?

    Thanx.



  • #2
    Welcome to Statalist. Present a data example using the dataex command illustrating your problem to increase your chances of getting a helpful reply (refer to FAQ Advice #12 for details).

    Comment


    • #3
      Thanks, got it sorted. Chat GPT helped :D Also that I realised that some variables were numerical and some strings, so I needed a complex code.

      Comment

      Working...
      X