Announcement

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

  • #16
    Sort of worked- I think the main issue here is the admission variable. Is there any way to code "admit=1" if LOS>=1 occurs at any time during the same visit date for the same identification number? I've attached a sample of the data that I get when running the above code. This person should be counted as admitted, and they are in some rows, but when I drop admit=0 I also end up dropping the fields containing the culture information and thus they aren't counted as having a culture when they really did have one. Is there any way to get every single row populated as admit=1? Then a simple browse would display all admitted individuals with cultures of interest.
    Attached Files

    Comment


    • #17
      If you are wondering about the clunky but hopefully correct coding for visit:

      Code:
      egen visit = group(ID Date)
      tempvar xvisit
      bysort ID (Date): gen `xvisit' = visit[1]
      bysort ID (Date): replace visit = visit - `xvisit' + 1
      Here is what happens after the first egen command: Suppose the person with the lowest id makes 5 visits. visit will be coded 1 through 5 for that person. The first visit of the next person will be coded 6, i.e. visit will just keep going up and up, it won't start over with each new person. Hence, the subsequent commands will start the numbering for visit all over again for each new person. e.g. if the 30th person's first visit was coded 117, 116 would be subtracted from each of the visit numbers for that person.

      I am assuming no missing data for either ID or Date; I am not sure what happens if there is and won't worry about it unless you say there sometimes is missing data on those two variables.
      -------------------------------------------
      Richard Williams, Notre Dame Dept of Sociology
      Stata Version: 17.0 MP (2 processor)

      EMAIL: [email protected]
      WWW: https://www3.nd.edu/~rwilliam

      Comment


      • #18
        In my code, you want to used admitted, not admit, to see if the person was admitted on that visit (as opposed to being admitted on one specific record from that visit).

        Have to go away for several hours -- good luck! I'll check later to see if you have declared final victory or not,.
        -------------------------------------------
        Richard Williams, Notre Dame Dept of Sociology
        Stata Version: 17.0 MP (2 processor)

        EMAIL: [email protected]
        WWW: https://www3.nd.edu/~rwilliam

        Comment


        • #19
          Megan wrote:
          I am currently using STATA 13 and the "quietly" command is unrecognized. Is there another option to try?
          .

          There was a little typo in Pierre Elias' code (not checked by me):
          Code:
          sort ID LOS
          quielty by ID: gen dup=cond(_N==1,0,_n)
          instead of:
          Code:
          sort ID LOS
          quietly by ID: gen dup=cond(_N==1,0,_n)
          Kind regards,
          Carlo
          Last edited by Carlo Lazzaro; 04 Sep 2014, 07:21.
          Kind regards,
          Carlo
          (StataNow 18.5)

          Comment

          Working...
          X