Announcement

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

  • Graph data with dates..(trend for large data)

    Hello,

    I have panel data starting from 2016 to 2019. I want to see the trend of drugs utilization during these years. Some doctors prescribe more than one medication in one year.

    I use this code, but the graph does not look the way I want. I want to have a horizontal line from 2016 to 2019

    I declare the data to be a panel.
    Code:
    egen id= group( prscrbr_npi gnrc_name )
    Code:
    tsset id date
    Code:
    twoway tsline  ratio
    Click image for larger version

Name:	Untitled.png
Views:	1
Size:	22.5 KB
ID:	1652908


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long prscrbr_npi str44 prscrbr_last_org_name str20(prscrbr_first_name prscrbr_state_abrvtn) str30 gnrc_name float(ratio date id)
    1003000126 "Enkeshafi"     "Ardalan"   "MD" "Ciprofloxacin Hcl"               .7333333 2016   1
    1003000126 "Enkeshafi"     "Ardalan"   "MD" "Furosemide"                     1.2941177 2017   2
    1003000126 "Enkeshafi"     "Ardalan"   "MD" "Pantoprazole Sodium"                 .375 2016   3
    1003000126 "Enkeshafi"     "Ardalan"   "MD" "Prednisone"                             1 2019   4
    1003000142 "Khalil"        "Rashid"    "OH" "Diclofenac Sodium"               .7037037 2018   5
    1003000142 "Khalil"        "Rashid"    "OH" "Diclofenac Sodium"              1.2105263 2019   5
    1003000407 "Girardi"       "David"     "PA" "Furosemide"                     1.7882353 2017   6
    1003000407 "Girardi"       "David"     "PA" "Pantoprazole Sodium"             .8333333 2016   7
    1003000522 "Weigand"       "Frederick" "FL" "Albuterol Sulfate"              1.4545455 2017   8
    1003000522 "Weigand"       "Frederick" "FL" "Albuterol Sulfate"               .9565217 2019   8
    1003000522 "Weigand"       "Frederick" "FL" "Amoxicillin/Potassium Clav"     1.0555556 2016   9
    1003000522 "Weigand"       "Frederick" "FL" "Atenolol"                        .8736842 2017  10
    1003000522 "Weigand"       "Frederick" "FL" "Atenolol/Chlorthalidone"            .6875 2018  11
    1003000522 "Weigand"       "Frederick" "FL" "Ciprofloxacin Hcl"               .6538461 2016  12
    1003000522 "Weigand"       "Frederick" "FL" "Ciprofloxacin Hcl"               .9230769 2018  12
    1003000522 "Weigand"       "Frederick" "FL" "Furosemide"                           1.2 2017  14
    1003000522 "Weigand"       "Frederick" "FL" "Levothyroxine Sodium"           1.0366973 2019  15
    1003000522 "Weigand"       "Frederick" "FL" "Lorazepam"                       .8809524 2018  16
    1003000522 "Weigand"       "Frederick" "FL" "Losartan Potassium"                    .8 2019  17
    1003000522 "Weigand"       "Frederick" "FL" "Methylprednisolone"                  1.15 2016  19
    1003000522 "Weigand"       "Frederick" "FL" "Nitrofurantoin Monohyd/M-Cryst"     1.125 2018  20
    1003000522 "Weigand"       "Frederick" "FL" "Pantoprazole Sodium"            1.1086956 2016  21
    1003000522 "Weigand"       "Frederick" "FL" "Potassium Chloride"             1.2435898 2019  22
    1003000522 "Weigand"       "Frederick" "FL" "Rosuvastatin Calcium"            .9814815 2018  24
    1003000522 "Weigand"       "Frederick" "FL" "Triamcinolone Acetonide"         .7435898 2019  26
    1003000522 "Weigand"       "Frederick" "FL" "Valsartan/Hydrochlorothiazide"   .8823529 2018  27
    1003000522 "Weigand"       "Frederick" "FL" "Verapamil Hcl"                          1 2019  28
    1003000530 "Semonche"      "Amanda"    "PA" "Albuterol Sulfate"                     .5 2017  29
    1003000530 "Semonche"      "Amanda"    "PA" "Albuterol Sulfate"              1.0952381 2019  29
    1003000530 "Semonche"      "Amanda"    "PA" "Amiodarone Hcl"                  .6190476 2018  30
    1003000530 "Semonche"      "Amanda"    "PA" "Amoxicillin/Potassium Clav"      .8571429 2016  31
    1003000530 "Semonche"      "Amanda"    "PA" "Atenolol"                               1 2017  32
    1003000530 "Semonche"      "Amanda"    "PA" "Buspirone Hcl"                  .52380955 2018  33
    1003000530 "Semonche"      "Amanda"    "PA" "Calcitriol"                     1.1666666 2016  34
    1003000530 "Semonche"      "Amanda"    "PA" "Diazepam"                           1.625 2017  36
    1003000530 "Semonche"      "Amanda"    "PA" "Doxycycline Hyclate"                    1 2016  37
    1003000530 "Semonche"      "Amanda"    "PA" "Fluticasone Propion/Salmeterol"       .75 2019  38
    1003000530 "Semonche"      "Amanda"    "PA" "Furosemide"                     1.0803572 2017  39
    1003000530 "Semonche"      "Amanda"    "PA" "Ipratropium Bromide"            1.2142857 2018  40
    1003000530 "Semonche"      "Amanda"    "PA" "Levothyroxine Sodium"            .9921466 2019  41
    1003000530 "Semonche"      "Amanda"    "PA" "Lorazepam"                       .9873418 2018  42
    1003000530 "Semonche"      "Amanda"    "PA" "Losartan Potassium"             1.1715976 2019  43
    1003000530 "Semonche"      "Amanda"    "PA" "Nitrofurantoin Monohyd/M-Cryst"     .6875 2018  45
    1003000530 "Semonche"      "Amanda"    "PA" "Pantoprazole Sodium"            1.5408163 2016  46
    1003000530 "Semonche"      "Amanda"    "PA" "Potassium Chloride"             .22222222 2019  47
    1003000530 "Semonche"      "Amanda"    "PA" "Rosuvastatin Calcium"               1.325 2018  49
    1003000530 "Semonche"      "Amanda"    "PA" "Venlafaxine Hcl"                 1.318182 2019  52
    1003000597 "Kim"           "Dae"       "OK" "Ciprofloxacin Hcl"               2.107143 2016  53
    1003000597 "Kim"           "Dae"       "OK" "Ciprofloxacin Hcl"               1.957143 2018  53
    1003000902 "Lohano"        "Jaivanti"  "KY" "Albuterol Sulfate"               .7236842 2017  54
    1003000902 "Lohano"        "Jaivanti"  "KY" "Albuterol Sulfate"                    .84 2019  54
    1003000902 "Lohano"        "Jaivanti"  "KY" "Amoxicillin/Potassium Clav"      .8666667 2016  55
    1003000902 "Lohano"        "Jaivanti"  "KY" "Atenolol"                               1 2017  56
    1003000902 "Lohano"        "Jaivanti"  "KY" "Carisoprodol"                    .8947368 2019  57
    1003000902 "Lohano"        "Jaivanti"  "KY" "Ciprofloxacin Hcl"                     .8 2016  58
    1003000902 "Lohano"        "Jaivanti"  "KY" "Ciprofloxacin Hcl"                    .92 2018  58
    1003000902 "Lohano"        "Jaivanti"  "KY" "Clonidine Hcl"                  1.1111112 2019  59
    1003000902 "Lohano"        "Jaivanti"  "KY" "Diclofenac Sodium"              1.0526316 2018  60
    1003000902 "Lohano"        "Jaivanti"  "KY" "Diclofenac Sodium"                   .775 2019  60
    1003000902 "Lohano"        "Jaivanti"  "KY" "Fluconazole"                     1.368421 2017  62
    1003000902 "Lohano"        "Jaivanti"  "KY" "Levetiracetam"                         .8 2019  64
    1003000902 "Lohano"        "Jaivanti"  "KY" "Lorazepam"                       .9701493 2018  66
    1003000902 "Lohano"        "Jaivanti"  "KY" "Losartan Potassium"                  1.25 2019  67
    1003000902 "Lohano"        "Jaivanti"  "KY" "Methylprednisolone"                   2.1 2016  69
    1003000902 "Lohano"        "Jaivanti"  "KY" "Ondansetron Hcl"                 .9206349 2018  70
    1003000902 "Lohano"        "Jaivanti"  "KY" "Pantoprazole Sodium"             1.122807 2016  71
    1003000902 "Lohano"        "Jaivanti"  "KY" "Potassium Chloride"              .4333333 2019  72
    1003000902 "Lohano"        "Jaivanti"  "KY" "Rosuvastatin Calcium"            .9117647 2018  74
    1003000902 "Lohano"        "Jaivanti"  "KY" "Venlafaxine Hcl"                 2.090909 2019  78
    1003000936 "Stellingworth" "Mark"      "SC" "Amiodarone Hcl"                  .9253731 2018  80
    1003000936 "Stellingworth" "Mark"      "SC" "Bumetanide"                     .56666666 2017  81
    1003000936 "Stellingworth" "Mark"      "SC" "Losartan Potassium"               .893617 2019  83
    1003000936 "Stellingworth" "Mark"      "SC" "Rosuvastatin Calcium"           1.2755102 2018  85
    1003001363 "Stevens"       "Charles"   "CA" "Diclofenac Sodium"                6.62963 2019  87
    1003001363 "Stevens"       "Charles"   "CA" "Hydromorphone Hcl"               1.117647 2017  88
    1003001363 "Stevens"       "Charles"   "CA" "Morphine Sulfate"               .22564103 2018  90
    1003001462 "Wolski"        "Michal"    "GA" "Amoxicillin/Potassium Clav"      1.846154 2016  91
    1003001645 "Trivedi"       "Vinod"     "CA" "Ciprofloxacin Hcl"              1.5357143 2018  93
    1003001645 "Trivedi"       "Vinod"     "CA" "Doxycycline Hyclate"            1.1578947 2016  94
    1003001645 "Trivedi"       "Vinod"     "CA" "Fluconazole"                       2.4375 2017  95
    1003001884 "Saha"          "Lucille"   "MI" "Ciprofloxacin Hcl"                    1.1 2016  97
    1003001884 "Saha"          "Lucille"   "MI" "Dicyclomine Hcl"                1.1428572 2019  98
    1003001884 "Saha"          "Lucille"   "MI" "Fluconazole"                    1.1666666 2017  99
    1003001884 "Saha"          "Lucille"   "MI" "Levothyroxine Sodium"             .886076 2019 101
    1003001884 "Saha"          "Lucille"   "MI" "Pantoprazole Sodium"             .7058824 2016 104
    1003001884 "Saha"          "Lucille"   "MI" "Potassium Chloride"              .7362638 2019 105
    1003001884 "Saha"          "Lucille"   "MI" "Rosuvastatin Calcium"            .7777778 2018 107
    1003001884 "Saha"          "Lucille"   "MI" "Venlafaxine Hcl"                1.2727273 2019 110
    1003002072 "Gotesman"      "Alexander" "NJ" "Ciprofloxacin Hcl"              1.8955224 2016 113
    1003002072 "Gotesman"      "Alexander" "NJ" "Ciprofloxacin Hcl"                     .6 2018 113
    1003002312 "Hopkins"       "Patricia"  "MA" "Albuterol Sulfate"                      1 2019 116
    1003002312 "Hopkins"       "Patricia"  "MA" "Atenolol"                        .7101449 2017 117
    1003002312 "Hopkins"       "Patricia"  "MA" "Diclofenac Sodium"              1.2941177 2018 119
    1003002312 "Hopkins"       "Patricia"  "MA" "Diclofenac Sodium"              1.2272727 2019 119
    1003002312 "Hopkins"       "Patricia"  "MA" "Doxycycline Hyclate"             .7073171 2016 120
    1003002312 "Hopkins"       "Patricia"  "MA" "Furosemide"                      1.451613 2017 121
    1003002312 "Hopkins"       "Patricia"  "MA" "Hydroxychloroquine Sulfate"      .7384616 2016 122
    1003002312 "Hopkins"       "Patricia"  "MA" "Levothyroxine Sodium"           1.0183486 2019 124
    1003002312 "Hopkins"       "Patricia"  "MA" "Lorazepam"                       .9302326 2018 125
    1003002312 "Hopkins"       "Patricia"  "MA" "Losartan Potassium"              1.304348 2019 126
    end

  • #2
    You're calling this panel data, but in your example data you have 90 distinct identifiers, most of which are observed only once. You can get a display of panels with more than one observation like this.

    Code:
    . bysort id : gen N = _N
    
    . xtline ratio if N > 1, overlay
    
    . xtline ratio if N > 1, overlay addplot(scatter ratio date if N == 1, ms(Oh))

    Comment

    Working...
    X