Announcement

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

  • create a new variable with a subset of observations from an existing variable

    Hello everyone,
    I have a variable that is a string, containing observations about patients' temperature. The observations are either "child does not fell hot", "child feels hot", or the temperature in degrees, from 30°C to 42°C.
    I would like to create a new variable containing only the observations of the measured temperature in degrees, to be able to destring it and use it as a numerical value.
    I am very new to stata, could someone please help me ? That would be of great help.
    All the best,
    Nina
    Attached Files

  • #2
    Please note comments on screenshots in the FAQ Advice #12.

    For once, brute force seems simpler and also just as effective as anything more subtle.


    Code:
    clear 
    input str42 basic 
    "child feels hot"
    "37.8" 
    end 
    
    gen wanted = real(basic)
    
    list 
    
         +--------------------------+
         |           basic   wanted |
         |--------------------------|
      1. | child feels hot        . |
      2. |            37.8     37.8 |
         +--------------------------+

    Comment


    • #3
      Thank you so much for your answer!
      I take note on the use of screenshots! Have a great day,
      Nina

      Comment

      Working...
      X