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

  • New variable, with value based on other variables

    hi - newbie question

    I'm trying to generate a new variable with values, base on other variables

    I'm working on a medical database and I have 2 variables (lab result and result value) as shown

    ID Lab test Result
    1 WBC 12.3
    1 Blood culture S. auerus

    I would like to generate a 3rd variable called "WBC"
    And replace the value to 12.3 for ID#1.

    ID Lab test Result WBC
    1 WBC 12.3 12.3
    1 Blood culture S. auerus

    What are the commands that I need use in order to do that?

    Anyone can tip in?

    Really appreciate your time in advance.

  • #2
    Welcome to Statalist.

    You have accidentally posted your topic in Statalist's Mata Forum, which is used for discussions of Stata's Mata language, which is different than Stata's command language. Your question will see a much larger audience if you post it in Statalist's General Forum.

    Also, if you have not already done so, take a look at the Statalist FAQ linked to at the top of this page for posting guidelines and suggestions.

    But beyond that, let me give you some advice about effectively learning the basics of Stata.When I began using Stata in a serious way, I started - as others here did - by reading my way through the Getting Started with Stata manual relevant to my setup. Chapter 18 then gives suggested further reading, much of which is in the Stata User's Guide, and I worked my way through much of that reading as well. All of these manuals are included as PDFs in the Stata installation and are accessible from within Stata - for example, through Stata's Help menu. The objective in doing this was not so much to master Stata as to be sure I'd become familiar with a wide variety of important basic techniques, so that when the time came that I needed them, I might recall their existence, if not the full syntax, and know how to find out more about them in the help files and manual.

    Stata supplies exceptionally good documentation that amply repays the time spent studying it - there's just a lot of it. The path I followed surfaces the things you need to know to get started in a hurry and to work effectively.