Announcement

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

  • Analysis of Subjects with Multiple Encounters

    Hello, new to the forum here. I'm a physician with a limited but thus far functional understanding of stata. I'm running into a problem with the following data set.

    The overall analysis is looking at the effect of a drug recall on patients receiving a particular eye injection. The time of the recall is defined as t0. Each patient's eye in the data set has a unique code. Each encounter (i.e. office visit) at which time a patient would have received an injection is its own row (detailing the drug received). Therefore, if a patient's eye had multiple injections, then there will be multiple rows with the same code for that eye. For the rows, e-1 is the encounter before t0, e-2 the penultimate before t0, etc. e1, e2, etc are for encounters after t0. I'm having an issue figuring out how to do the analysis below in this nested layout of my data.

    What would be the best commands for the following:
    - Analyzing how many injections were received by each patient prior to t0
    - How many patients switched drug from e-1 to e1 (before and after the recall)
    - Categorizing the diagnostic indication for each eye (i.e. not by row but rather by eye).

    I have tried searching in the manual and online, but I have hit a will. Hope my questions are clear- if not happy to clarify. Again, I'm primarily a clinical physician.

    Appreciate any help.




  • #2
    It will surprise me if anybody can answer this question based on the information presented. Even the most careful explanation in words of a data set is rarely adequate to support development of code.

    I recommend that you post back showing example data from your data set. Use the -dataex- command to do that. If you are running version 18, 17, 16 or a fully updated version 15.1 or 14.2, -dataex- 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.

    Comment


    • #3
      Thanks for the suggestion. Had an issue with dataex (possibly because of the size of the data set). I have instead posted a condensed sample (removed many variables to keep anonymous/make it easier to read) from the Excel data sheet I'm working from.

      PersonID=Patient level
      SubjectID: Eye level data
      Encounter number - all relative to T0 which is the recall date we are interested in
      Injection number - again relative to T0, the recall date
      Drug - Type of injection administered (names will be coded for the analysis, ignore empty cells, just encounters where a drug was not administered)

      I am interested in data at the eye level (i.e. subjectID). Each eye may have several rows because it may have received multiple injections at multiple encounters

      Again, looking to analyze for example the following questions:
      - Analyzing how many injections were received by each eye (i.e. subjectID)
      - How many patients switched drug from e-1 to e1 (before and after the recall)
      - Comparing logmar by SubjectID from e-1 to e1
      PersonID SubjectID SubjectEye Days Before or After Recall Encounter Number (Relative to T0) Injection Number (Relative to T0) Interval Drug logMAR
      0A41087C0DFCA6A83879415F72542663 B65D351611CFAB93BDEFE053B732C6EB Right -118 -2 -2 0.87506126
      0A41087C0DFCA6A83879415F72542663 B65D351611CFAB93BDEFE053B732C6EB Right -97 -1 -1 AVASTIN 1.09691001
      0AA0FB142EDE523F30BAF3C7C1ADC27D B1209C5C5659D8C7F1B6B9958C91B2C9 Right -3 -1 -1 1.8
      0AA0FB142EDE523F30BAF3C7C1ADC27D B1209C5C5659D8C7F1B6B9958C91B2C9 Right 2 1 1 -35 AVASTIN 0.69897
      0AA0FB142EDE523F30BAF3C7C1ADC27D B1209C5C5659D8C7F1B6B9958C91B2C9 Right 37 2 2 AVASTIN 0.39794001
      0AB4133CFF9D354B141976CEEAB7F55D EC841715095AA5E6408529931FA34C4E Right -47 -2 -2 -28 AVASTIN 1.24303805
      0AB4133CFF9D354B141976CEEAB7F55D EC841715095AA5E6408529931FA34C4E Right -19 -1 -1 -35 AVASTIN 1.24303805
      0AB4133CFF9D354B141976CEEAB7F55D EC841715095AA5E6408529931FA34C4E Right 15 1 1 -28 AVASTIN 1
      0AB4133CFF9D354B141976CEEAB7F55D EC841715095AA5E6408529931FA34C4E Right 43 2 2 AVASTIN
      0AB670293AEAB6109E8F864229458D97 15531923EFC1DD1BE4EFCF4DACE65245 Left -171 -2 -2 -70 AVASTIN 0.39794001
      0AB670293AEAB6109E8F864229458D97 15531923EFC1DD1BE4EFCF4DACE65245 Left -101 -1 -1 AVASTIN 0.30103
      0AE1E0F30C33DE7FB959EC88E3D1E03E 615350DCA8DE7EB37166B2A59B8B3431 Left -178 -6 -6 -29 AVASTIN 0.47712125
      0AE1E0F30C33DE7FB959EC88E3D1E03E 615350DCA8DE7EB37166B2A59B8B3431 Left -149 -5 -5 -35 AVASTIN 0.54406804
      0AE1E0F30C33DE7FB959EC88E3D1E03E 615350DCA8DE7EB37166B2A59B8B3431 Left -114 -4 -4 -175 AVASTIN 0.69897
      0AE1E0F30C33DE7FB959EC88E3D1E03E 615350DCA8DE7EB37166B2A59B8B3431 Left -86 -3 -3 0.60205999
      0AE1E0F30C33DE7FB959EC88E3D1E03E 615350DCA8DE7EB37166B2A59B8B3431 Left -44 -2 -2 0.54406804
      0AE1E0F30C33DE7FB959EC88E3D1E03E 615350DCA8DE7EB37166B2A59B8B3431 Left -2 -1 -1 0.60205999
      0AE1E0F30C33DE7FB959EC88E3D1E03E 615350DCA8DE7EB37166B2A59B8B3431 Left 60 1 1 EYLEA 0.47712125
      0AE79B536650BDBA52C9EC3DB0020BD5 74742115B85F01B428907866D6A0FD77 Left -152 -3 -3 -70 AVASTIN 1
      0AE79B536650BDBA52C9EC3DB0020BD5 74742115B85F01B428907866D6A0FD77 Left -82 -2 -2 -57 AVASTIN 0.87506126
      0AE79B536650BDBA52C9EC3DB0020BD5 74742115B85F01B428907866D6A0FD77 Left -25 -1 -1 -62 AVASTIN 0.87506126
      0AE79B536650BDBA52C9EC3DB0020BD5 74742115B85F01B428907866D6A0FD77 Left 36 1 1 AVASTIN 0.87506126
      0AF9CAF31DD5402B89280E4B4FE7207C 55162476A1186A566191801356005517 Left -146 -2 -2 -99 AVASTIN 2.2
      0AF9CAF31DD5402B89280E4B4FE7207C 55162476A1186A566191801356005517 Left -47 -1 -1 -97 AVASTIN 2.2
      0AF9CAF31DD5402B89280E4B4FE7207C 55162476A1186A566191801356005517 Left 49 1 1 AVASTIN 2.2
      0BDCB30D962016C2C26D9E045E90FE08 E55B59DBD12FC2DD95A0CEF3DFF8D887 Left -132 -1 -1 AVASTIN 0.60205999
      0BDD1E0D9E4B781757B6FF8919C9E4E3 EDEDC591E14F484066953BCFF3583608 Right -145 -2 -2 -104 AVASTIN 0.39794001
      0BDD1E0D9E4B781757B6FF8919C9E4E3 EDEDC591E14F484066953BCFF3583608 Right -41 -1 -1 AVASTIN 0.30103
      0C5E91426D746B15855198809122D903 327D66D9D4E9CC0B006EF0DC30503518 Left -132 -2 -2 -84 AVASTIN 0
      0C5E91426D746B15855198809122D903 327D66D9D4E9CC0B006EF0DC30503518 Left -48 -1 -1 -84 AVASTIN 0.09691001
      0C5E91426D746B15855198809122D903 327D66D9D4E9CC0B006EF0DC30503518 Left 35 1 1 AVASTIN 0
      0C8C8288739FF11D1DDD3F76A42ECC91 9239570C94B2EF82166F49EA04EB66D0 Right -152 -2 -2 -84 AVASTIN 0.87506126
      0C8C8288739FF11D1DDD3F76A42ECC91 9239570C94B2EF82166F49EA04EB66D0 Right -68 -1 -1 -85 AVASTIN 0.87506126
      0C8C8288739FF11D1DDD3F76A42ECC91 9239570C94B2EF82166F49EA04EB66D0 Right 16 1 1 CIMERLI 0.87506126
      0CC7C1D71DCFCF107BED3515A8555D47 EAF654BA7C64E0E1FE2D2C130F670DCE Left -139 -2 -3 AVASTIN 0.47712125
      0CC7C1D71DCFCF107BED3515A8555D47 EAF654BA7C64E0E1FE2D2C130F670DCE Left -41 -1 -2 0.54406804
      0CC7C1D71DCFCF107BED3515A8555D47 EAF654BA7C64E0E1FE2D2C130F670DCE Left 21 1 -1 0.47712125
      0CD52628AC925ED60C7A0CBFAEC2DF1A 95425F119B5ACDD321E44B1EB1EA0F19 Left -178 -8 -9 0.69897
      0CD52628AC925ED60C7A0CBFAEC2DF1A 95425F119B5ACDD321E44B1EB1EA0F19 Left -152 -7 -8 0.87506126
      0CD52628AC925ED60C7A0CBFAEC2DF1A 95425F119B5ACDD321E44B1EB1EA0F19 Left -138 -6 -7 0.87506126
      0CD52628AC925ED60C7A0CBFAEC2DF1A 95425F119B5ACDD321E44B1EB1EA0F19 Left -124 -5 -6 AVASTIN 0.87506126
      0CD52628AC925ED60C7A0CBFAEC2DF1A 95425F119B5ACDD321E44B1EB1EA0F19 Left -96 -4 -5 0.87506126
      0CD52628AC925ED60C7A0CBFAEC2DF1A 95425F119B5ACDD321E44B1EB1EA0F19 Left -61 -3 -4 0.69897
      0CD52628AC925ED60C7A0CBFAEC2DF1A 95425F119B5ACDD321E44B1EB1EA0F19 Left -13 -2 -3 0.69897
      0CD52628AC925ED60C7A0CBFAEC2DF1A 95425F119B5ACDD321E44B1EB1EA0F19 Left -5 -1 -2 0.69897
      0CD52628AC925ED60C7A0CBFAEC2DF1A 95425F119B5ACDD321E44B1EB1EA0F19 Left 29 1 -1 0.69897
      0CD53908CB92CCB9FD7B92640B40F9F9 48B9FAE42A5588D4F52CD9CB24074C0F Right -114 -2 -2 -101 AVASTIN 0.39794001
      0CD53908CB92CCB9FD7B92640B40F9F9 48B9FAE42A5588D4F52CD9CB24074C0F Right -13 -1 -1 AVASTIN 0.17609126
      0CD69076FD59F188C8E994ED1E77343E 289B557518D16578420349A2DA2C2782 Left -114 -2 -2 -98 AVASTIN 0.17609126
      0CD69076FD59F188C8E994ED1E77343E 289B557518D16578420349A2DA2C2782 Left -16 -1 -1 AVASTIN 0.09691001
      0CFE3D6662B46E2E861F7B806C971886 83E9721C0509C2E6BDCF570ECD2A27F1 Left -137 -2 -2 0.39794001
      0CFE3D6662B46E2E861F7B806C971886 83E9721C0509C2E6BDCF570ECD2A27F1 Left -101 -1 -1 -112 AVASTIN 2.1
      0CFE3D6662B46E2E861F7B806C971886 83E9721C0509C2E6BDCF570ECD2A27F1 Left 10 1 1 EYLEA 2.2
      00D1BB409256E80B55C477976BD600B8 CC720FF752645836C5FEB5C78145A68F Right -12 -2 -2 0.69897
      00D1BB409256E80B55C477976BD600B8 CC720FF752645836C5FEB5C78145A68F Right -5 -1 -1 -28 AVASTIN 1
      00D1BB409256E80B55C477976BD600B8 CC720FF752645836C5FEB5C78145A68F Right 22 1 1 AVASTIN 0.47712125

      Comment


      • #4
        Your data example as posted is quite messy to work with, and won't much help people help you for reasons too lengthy to explain here. It's quite possible to use -dataex- to display example data for a limited number of observations and variables, which I'm guessing (?) will help you. Try the following to produce a workable -dataex- example that you can post here:

        Code:
        encode PersonID, generate(pid)
        dataex pid  PersonID  SubjectID SubjectEye etc. if inlist(PersonID,1, 2, 3)
        The preceding will enable you to get a -dataex- listing for the 3 persons and your chosen selection of variables. The individuals chosen will be the first three in alphabetical order of PersonID, which may not be optimal to reveal the details of your data, but would be a good start, and will be much more readable. Where I show "etc." you need to include a list, separated by spaces, of the variable names of interest.
        (You might benefit by refreshing your memory by looking again at some of the examples shown by -help dataex-) This should produce a listing you can post back here. If this doesn't work for you, ask for more help with -dataex-, explaining just what your problem with it was.

        Comment

        Working...
        X