Announcement

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

  • coding for "previous nearest value"

    I would like to compare weight gain in my cohort of babies at different stages, e.g. before and after stoma closure. I have 20 patients (17 survivors) listed by record_id. Each has a set of data that was checked at 6-14 day intervals. The relevant variables that need to be incorporated are:
    record_id
    wtgainperday (weight gain per day)
    ageweight (recording the age in days that weight gain was calculated)
    ageclos (the age of baby when stoma closed NB there may not be a weight gain per day calculation on the same day as ageclos, so need help to code for "previous nearest wtgainperday")
    Thank you

  • #2
    Welcome to Statalist.

    A couple of tips to increase your chances of getting a timely and helpful response.

    First, don't use jargon. I"m an epidemiologist, so I know what stoma closure means, but most Forum members will not. If it were relevant to getting the right answer to your question, it would need to be explained in plain English. As it is not relevant, there is no need to mention it at all. Using jargon just discourages people from reading on and answering.

    Second, when you want help with code, always show example data. The code almost invariably depends on details of the data organization that are not easily described in words. Even when the relevant facts about the data can be written in sentences, it still helps those who want to help you if they have example data they can try their code out on to be sure it really works with your data. To show example data, please use the -dataex- command. If you are running version 15.1 or a fully updated version 14.2, it is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    Finally, you will need to explain what "previous nearest value" means. I can imagine at least two different things it might mean. Perhaps after you post back with example data you can point to some observations in your example and explain what the previous nearest value for them would be and why those are what you want.

    Comment

    Working...
    X