Dear Statalists,

I am using Stata/MP 16.1 to analyze a large dataset (200,000 obs.) of investor lead manager relationships. I want to count how many times any investor has worked with the lead underwriter within 1825 days. Another thing I want to count is count how many times any investor has worked with the lead underwriter in the hot IPO (the variable HOTIPO = 1). I used -rangestat-, but it seems that it can only use year interval but not days. Here's the code I used:
gen long obs_no = _n
rangestat (count) wanted = obs_no, by( Investor LeadManager ) interval(year -5 -1).

Thank you so much your time and help!

The data example is:
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input int IssueDate str31(StockName Investor) str30 LeadManager byte(HOTIPO NumberofLeadManagers) float year long obs_no double wanted
18828 "SUNCOKE ENERGY INC."             "1798 GLOBAL PTNR (CAYMAN) LTD"  "BOA-MERRILL"         0 3 2011   1 .
18786 "FUSION-IO INC."                  "1798 GLOBAL PTNR (CAYMAN) LTD"  "CREDIT-SUISSE"       1 4 2011   2 .
18828 "SUNCOKE ENERGY INC."             "1798 GLOBAL PTNR (CAYMAN) LTD"  "CREDIT-SUISSE"       0 3 2011   3 .
18786 "FUSION-IO INC."                  "1798 GLOBAL PTNR (CAYMAN) LTD"  "GS"                  1 4 2011   4 .
18828 "SUNCOKE ENERGY INC."             "1798 GLOBAL PTNR (CAYMAN) LTD"  "GS"                  0 3 2011   5 .
18786 "FUSION-IO INC."                  "1798 GLOBAL PTNR (CAYMAN) LTD"  "JP Morgan (JPM)"     1 4 2011   6 .
18786 "FUSION-IO INC."                  "1798 GLOBAL PTNR (CAYMAN) LTD"  "Morgan Stanley & Co" 1 4 2011   7 .
20669 "AT HOME GROUP INC."              "1ST GLOBAL ADVISORS, INC"       "BOA-MERRILL"         0 4 2016   8 .
20740 "MAMMOTH ENERGY SERVICES INC."    "1ST GLOBAL ADVISORS, INC"       "Barclays Capital"    0 3 2016   9 .
20746 "FORTERRA INC."                   "1ST GLOBAL ADVISORS, INC"       "Barclays Capital"    0 6 2016  10 .
20746 "FORTERRA INC."                   "1ST GLOBAL ADVISORS, INC"       "CITIGROUP"           0 6 2016  11 .
20740 "MAMMOTH ENERGY SERVICES INC."    "1ST GLOBAL ADVISORS, INC"       "CREDIT-SUISSE"       0 3 2016  12 .
20746 "FORTERRA INC."                   "1ST GLOBAL ADVISORS, INC"       "CREDIT-SUISSE"       0 6 2016  13 .
20746 "FORTERRA INC."                   "1ST GLOBAL ADVISORS, INC"       "DEUTSCHE-BANK"       0 6 2016  14 .
20746 "FORTERRA INC."                   "1ST GLOBAL ADVISORS, INC"       "GS"                  0 6 2016  15 .
20669 "AT HOME GROUP INC."              "1ST GLOBAL ADVISORS, INC"       "GS"                  0 4 2016  16 .
20669 "AT HOME GROUP INC."              "1ST GLOBAL ADVISORS, INC"       "JEFFERIES"           0 4 2016  17 .
20669 "AT HOME GROUP INC."              "1ST GLOBAL ADVISORS, INC"       "Morgan Stanley & Co" 0 4 2016  18 .
20740 "MAMMOTH ENERGY SERVICES INC."    "1ST GLOBAL ADVISORS, INC"       "Piper Jaffray Inc"   0 3 2016  19 .
20746 "FORTERRA INC."                   "1ST GLOBAL ADVISORS, INC"       "RBC Capital Markets" 0 6 2016  20 .
18946 "CLOVIS ONCOLOGY INC."            "ABINGWORTH LLP"                 "CREDIT-SUISSE"       0 2 2011  21 .
20717 "NOVAN INC."                      "ABINGWORTH LLP"                 "JMP-SEC"             1 3 2016  22 .
18946 "CLOVIS ONCOLOGY INC."            "ABINGWORTH LLP"                 "JP Morgan (JPM)"     0 2 2011  23 .
20717 "NOVAN INC."                      "ABINGWORTH LLP"                 "Piper Jaffray Inc"   1 3 2016  24 .
20717 "NOVAN INC."                      "ABINGWORTH LLP"                 "WEDBUSH-SEC"         1 3 2016  25 .
20649 "ADVANCEPIERRE FOODS HLDG INC."   "ACADIAN ASSET MANAGEMENT LLC"   "BMO-CAPITAL"         1 6 2016  26 .
20649 "ADVANCEPIERRE FOODS HLDG INC."   "ACADIAN ASSET MANAGEMENT LLC"   "Barclays Capital"    1 6 2016  27 .
20649 "ADVANCEPIERRE FOODS HLDG INC."   "ACADIAN ASSET MANAGEMENT LLC"   "CREDIT-SUISSE"       1 6 2016  28 .
20649 "ADVANCEPIERRE FOODS HLDG INC."   "ACADIAN ASSET MANAGEMENT LLC"   "DEUTSCHE-BANK"       1 6 2016  29 .
20649 "ADVANCEPIERRE FOODS HLDG INC."   "ACADIAN ASSET MANAGEMENT LLC"   "GS"                  1 6 2016  30 .
20649 "ADVANCEPIERRE FOODS HLDG INC."   "ACADIAN ASSET MANAGEMENT LLC"   "Morgan Stanley & Co" 1 6 2016  31 .
18695 "HCA HOLDINGS INC."               "ACCIPITER CAPITAL MGMT, L.L.C." "BOA-MERRILL"         0 9 2011  32 .
18695 "HCA HOLDINGS INC."               "ACCIPITER CAPITAL MGMT, L.L.C." "Barclays Capital"    0 9 2011  33 .
18695 "HCA HOLDINGS INC."               "ACCIPITER CAPITAL MGMT, L.L.C." "CITIGROUP"           0 9 2011  34 .
18695 "HCA HOLDINGS INC."               "ACCIPITER CAPITAL MGMT, L.L.C." "CREDIT-SUISSE"       0 9 2011  35 .
18695 "HCA HOLDINGS INC."               "ACCIPITER CAPITAL MGMT, L.L.C." "DEUTSCHE-BANK"       0 9 2011  36 .
18695 "HCA HOLDINGS INC."               "ACCIPITER CAPITAL MGMT, L.L.C." "GS"                  0 9 2011  37 .
18695 "HCA HOLDINGS INC."               "ACCIPITER CAPITAL MGMT, L.L.C." "JP Morgan (JPM)"     0 9 2011  38 .
18695 "HCA HOLDINGS INC."               "ACCIPITER CAPITAL MGMT, L.L.C." "Morgan Stanley & Co" 0 9 2011  39 .
18695 "HCA HOLDINGS INC."               "ACCIPITER CAPITAL MGMT, L.L.C." "WELLS-FARGO"         0 9 2011  40 .
20614 "ATKORE INTERNATIONAL GROUP INC." "ACK ASSET MANAGEMENT LLC"       "CITIGROUP"           0 7 2016  41 .
20614 "ATKORE INTERNATIONAL GROUP INC." "ACK ASSET MANAGEMENT LLC"       "CREDIT-SUISSE"       0 7 2016  42 .
20614 "ATKORE INTERNATIONAL GROUP INC." "ACK ASSET MANAGEMENT LLC"       "DEUTSCHE-BANK"       0 7 2016  43 .
20614 "ATKORE INTERNATIONAL GROUP INC." "ACK ASSET MANAGEMENT LLC"       "JP Morgan (JPM)"     0 7 2016  44 .
20614 "ATKORE INTERNATIONAL GROUP INC." "ACK ASSET MANAGEMENT LLC"       "RBC Capital Markets" 0 7 2016  45 .
20614 "ATKORE INTERNATIONAL GROUP INC." "ACK ASSET MANAGEMENT LLC"       "UBS Investment Bank" 0 7 2016  46 .
20614 "ATKORE INTERNATIONAL GROUP INC." "ACK ASSET MANAGEMENT LLC"       "WELLS-FARGO"         0 7 2016  47 .
18750 "BOINGO WIRELESS INC."            "ACT II CAPITAL, LLC"            "CREDIT-SUISSE"       0 2 2011  48 .
18834 "TANGOE INC."                     "ACT II CAPITAL, LLC"            "DEUTSCHE-BANK"       1 2 2011  49 .
18750 "BOINGO WIRELESS INC."            "ACT II CAPITAL, LLC"            "DEUTSCHE-BANK"       0 2 2011  50 .
18834 "TANGOE INC."                     "ACT II CAPITAL, LLC"            "STIFEL"              1 2 2011  51 .
20752 "RA PHARMACEUTICALS INC."         "ACUTA CAPITAL PARTNERS, LLC"    "BMO-CAPITAL"         0 4 2016  52 .
20752 "RA PHARMACEUTICALS INC."         "ACUTA CAPITAL PARTNERS, LLC"    "CREDIT-SUISSE"       0 4 2016  53 .
20752 "RA PHARMACEUTICALS INC."         "ACUTA CAPITAL PARTNERS, LLC"    "JEFFERIES"           0 4 2016  54 .
20752 "RA PHARMACEUTICALS INC."         "ACUTA CAPITAL PARTNERS, LLC"    "SUNTRUST-RH"         0 4 2016  55 .
20752 "RA PHARMACEUTICALS INC."         "ADAGE CAPITAL MANAGEMENT, L.P." "BMO-CAPITAL"         0 4 2016  56 .
20676 "PROTAGONIST THERAPEUTICS INC."   "ADAGE CAPITAL MANAGEMENT, L.P." "BMO-CAPITAL"         0 3 2016  57 .
20494 "AVEXIS INC."                     "ADAGE CAPITAL MANAGEMENT, L.P." "BMO-CAPITAL"         0 3 2016  58 .
18827 "SKULLCANDY INC."                 "ADAGE CAPITAL MANAGEMENT, L.P." "BOA-MERRILL"         0 2 2011  59 .
18695 "HCA HOLDINGS INC."               "ADAGE CAPITAL MANAGEMENT, L.P." "BOA-MERRILL"         0 9 2011  60 .
20654 "AUDENTES THERAPEUTICS INC."      "ADAGE CAPITAL MANAGEMENT, L.P." "BOA-MERRILL"         0 3 2016  61 2
20738 "EXTRACTION OIL & GAS INC."       "ADAGE CAPITAL MANAGEMENT, L.P." "Barclays Capital"    1 8 2016  62 2
18668 "KINDER MORGAN INC."              "ADAGE CAPITAL MANAGEMENT, L.P." "Barclays Capital"    0 2 2011  63 .
20676 "PROTAGONIST THERAPEUTICS INC."   "ADAGE CAPITAL MANAGEMENT, L.P." "Barclays Capital"    0 3 2016  64 2
18695 "HCA HOLDINGS INC."               "ADAGE CAPITAL MANAGEMENT, L.P." "Barclays Capital"    0 9 2011  65 .
20719 "VALVOLINE INC."                  "ADAGE CAPITAL MANAGEMENT, L.P." "CITIGROUP"           0 6 2016  66 1
20738 "EXTRACTION OIL & GAS INC."       "ADAGE CAPITAL MANAGEMENT, L.P." "CITIGROUP"           1 8 2016  67 1
18695 "HCA HOLDINGS INC."               "ADAGE CAPITAL MANAGEMENT, L.P." "CITIGROUP"           0 9 2011  68 .
20654 "AUDENTES THERAPEUTICS INC."      "ADAGE CAPITAL MANAGEMENT, L.P." "COWEN"               0 3 2016  69 .
20738 "EXTRACTION OIL & GAS INC."       "ADAGE CAPITAL MANAGEMENT, L.P." "CREDIT-SUISSE"       1 8 2016  70 1
18695 "HCA HOLDINGS INC."               "ADAGE CAPITAL MANAGEMENT, L.P." "CREDIT-SUISSE"       0 9 2011  71 .
20752 "RA PHARMACEUTICALS INC."         "ADAGE CAPITAL MANAGEMENT, L.P." "CREDIT-SUISSE"       0 4 2016  72 1
20676 "MEDPACE INC."                    "ADAGE CAPITAL MANAGEMENT, L.P." "CREDIT-SUISSE"       1 4 2016  73 1
18695 "HCA HOLDINGS INC."               "ADAGE CAPITAL MANAGEMENT, L.P." "DEUTSCHE-BANK"       0 9 2011  74 .
20719 "VALVOLINE INC."                  "ADAGE CAPITAL MANAGEMENT, L.P." "DEUTSCHE-BANK"       0 6 2016  75 1
20494 "AVEXIS INC."                     "ADAGE CAPITAL MANAGEMENT, L.P." "GS"                  0 3 2016  76 2
20738 "EXTRACTION OIL & GAS INC."       "ADAGE CAPITAL MANAGEMENT, L.P." "GS"                  1 8 2016  77 2
18668 "KINDER MORGAN INC."              "ADAGE CAPITAL MANAGEMENT, L.P." "GS"                  0 2 2011  78 .
18695 "HCA HOLDINGS INC."               "ADAGE CAPITAL MANAGEMENT, L.P." "GS"                  0 9 2011  79 .
20719 "VALVOLINE INC."                  "ADAGE CAPITAL MANAGEMENT, L.P." "GS"                  0 6 2016  80 2
20676 "MEDPACE INC."                    "ADAGE CAPITAL MANAGEMENT, L.P." "JEFFERIES"           1 4 2016  81 .
20671 "GEMPHIRE THERAPEUTICS INC."      "ADAGE CAPITAL MANAGEMENT, L.P." "JEFFERIES"           0 2 2016  82 .
20752 "RA PHARMACEUTICALS INC."         "ADAGE CAPITAL MANAGEMENT, L.P." "JEFFERIES"           0 4 2016  83 .
20494 "AVEXIS INC."                     "ADAGE CAPITAL MANAGEMENT, L.P." "JEFFERIES"           0 3 2016  84 .
20719 "ELF BEAUTY INC."                 "ADAGE CAPITAL MANAGEMENT, L.P." "JP Morgan (JPM)"     1 4 2016  85 1
20719 "VALVOLINE INC."                  "ADAGE CAPITAL MANAGEMENT, L.P." "JP Morgan (JPM)"     0 6 2016  86 1
18695 "HCA HOLDINGS INC."               "ADAGE CAPITAL MANAGEMENT, L.P." "JP Morgan (JPM)"     0 9 2011  87 .
20738 "EXTRACTION OIL & GAS INC."       "ADAGE CAPITAL MANAGEMENT, L.P." "KEYBANC"             1 8 2016  88 .
20676 "PROTAGONIST THERAPEUTICS INC."   "ADAGE CAPITAL MANAGEMENT, L.P." "LEERINK-PARTNER"     0 3 2016  89 .
20719 "VALVOLINE INC."                  "ADAGE CAPITAL MANAGEMENT, L.P." "ML"                  0 6 2016  90 .
18827 "SKULLCANDY INC."                 "ADAGE CAPITAL MANAGEMENT, L.P." "Morgan Stanley & Co" 0 2 2011  91 .
18695 "HCA HOLDINGS INC."               "ADAGE CAPITAL MANAGEMENT, L.P." "Morgan Stanley & Co" 0 9 2011  92 .
20719 "VALVOLINE INC."                  "ADAGE CAPITAL MANAGEMENT, L.P." "Morgan Stanley & Co" 0 6 2016  93 2
20719 "ELF BEAUTY INC."                 "ADAGE CAPITAL MANAGEMENT, L.P." "Morgan Stanley & Co" 1 4 2016  94 2
20654 "AUDENTES THERAPEUTICS INC."      "ADAGE CAPITAL MANAGEMENT, L.P." "PIPER-MUNI"          0 3 2016  95 .
20719 "ELF BEAUTY INC."                 "ADAGE CAPITAL MANAGEMENT, L.P." "Piper Jaffray Inc"   1 4 2016  96 .
20738 "EXTRACTION OIL & GAS INC."       "ADAGE CAPITAL MANAGEMENT, L.P." "RBC Capital Markets" 1 8 2016  97 .
20671 "GEMPHIRE THERAPEUTICS INC."      "ADAGE CAPITAL MANAGEMENT, L.P." "RBC Capital Markets" 0 2 2016  98 .
20752 "RA PHARMACEUTICALS INC."         "ADAGE CAPITAL MANAGEMENT, L.P." "SUNTRUST-RH"         0 4 2016  99 .
20738 "EXTRACTION OIL & GAS INC."       "ADAGE CAPITAL MANAGEMENT, L.P." "SUNTRUST-RH"         1 8 2016 100 .
end
format %tdnn/dd/CCYY IssueDate
------------------ copy up to and including the previous line ------------------