Announcement

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

  • #16
    Thank you prof. Schechter.
    Before using the command I will try to consult with someone who worked on this dataset before. I will update you.

    Comment


    • #17
      Dear prof. Schechter,

      I will have additional variables which is different for each script. Hope this will help me distinguish the original script and duplicates. I will repeat the analysis again when additional data will be available in few weeks.


      Now I am trying to prepare dataset for merging with another dataset. But in order to do this each observation should correspond to a single individual.
      I tried to reshape data into wide format but no result.

      I would really appreciate if you may help me to solve the problem.


      Thank you so much.

      Data looks as below:

      clear
      input str11 drug byte pat_id int(supp_date index_date date_of_death) float(pdc_12mth pdc_12mth_80)
      "aspirin" 1 507 507 . .6191781 1
      "aspirin" 1 518 507 . .6191781 1
      "clopidogrel" 1 518 507 . .16438356 1
      "clopidogrel" 2 517 517 . .3068493 1
      "clopidogrel" 2 520 517 599 . 2
      "statin" 2 520 517 . .24657534 1
      "aspirin" 3 553 552 . .6958904 1
      "aspirin" 3 584 552 . .6958904 1
      "aspirin" 3 586 552 608 . 2
      "clopidogrel" 3 584 552 . .08219178 1
      "clopidogrel" 3 586 552 608 . 2
      "fibrate" 3 552 552 . .16438356 1
      "statin" 3 589 552 . .07671233 1
      "clopidogrel" 4 533 533 . .07671233 1
      "fibrate" 4 533 533 . .07671233 1
      "fibrate" 4 557 533 592 . 2
      "clopidogrel" 5 520 520 . .5205479 1
      "clopidogrel" 5 524 520 . .5205479 1
      "clopidogrel" 5 535 520 605 . 2
      "fibrate" 5 524 520 . .2739726 1
      "statin" 5 535 520 605 . 2
      end
      format %tm supp_date
      format %tm index_date
      format %tm date_of_death

      Comment


      • #18
        Now I am trying to prepare dataset for merging with another dataset. But in order to do this each observation should correspond to a single individual.
        Why? If the other file has one observation per individual, you can still merge it with the data you have by using -merge m:1- or -merge 1:m- (depending on which data set is in memory and which is the -using- file). Do you have a really persuasive reason why you need to reduce this data to one observation per person? Because, remember that when you want to go on and analyze this data you will almost certainly need to put it back into long layout again. So why this roundabout approach?

        I tried to reshape data into wide format but no result.
        What does this mean? There are many things you might have tried that somehow involve the -reshape- command, but you don't actually say what you did. And "no result." Really? Stata just crashed, or hung? Nothing at all happened? That seems unlikely. Maybe you didn't get the results you wanted, but I would bet that something happened. Error messages, perhaps?

        I can't troubleshoot imaginary code and imaginary problems. You have to show exactly what you did and exactly what you got.

        Now, assuming there really is a good reason to make one observation per person, you need to explain what the observation is going to look like. For one thing, even for a given pat_id drug combination, there are multiple records, sometimes corresponding to different supp_date's. So how do we deal with that. Do we have separate variables for each supp_date's data? If so, should the name of the variable mention the date itself, or would names like aspirin1 aspirin2 aspirin3, etc. be sufficient for your purposes? Or do we add up the totals for each drug regardless of supp_date and just have one variable for each drug? Or something else? Also, in the example you show here, there is only one observation for each combination of pat_id, drug, and supp_date. But in some of your earlier examples, there could be multiple observations with the same pat_id, drug, and supp_date. What is the case in the data you are trying to work with here?

        Comment

        Working...
        X