Announcement

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

  • Loop not identifying the local of variable suffixes

    Hi. I am trying to run the loop below over several individual datasets for the years 2007-2012. Some of the variables in each dataset have a year identifying suffix - 07X, 08X, etc. I am trying to run the loop below but get the following error: "08X invalid name". I've tried different combinations but all appear to yield the same error. I am also attaching a sample of 2007 dataset.

    Code:
    cd "$data"
    
    local time "2007 2008 2009 2010 2011 2012"
    local x "07X 08X 09X 10X 11X 12X"
    local f "07F 08F 09F 10F 11F 12F"
    
    foreach time in `time'{
      * import files
        use "P`time'", clear
      *keeping only the variables that matter - id, weight, payment vars & drug code and name
        keep DUPERSID RXNDC PERWT`f' RXSF`x' RXMR`x' RXMD`x' RXPV`x' RXXP`x' RXNAME
      
      *converting var names to lowercase
        rename *, lower 
      
      //Data is in long form by id and drug code - collapsing on drug code  condl on id
      //calculating totals and averages by id and drug code
    
        collapse (sum) rxsf`x' rxmr`x' rxmd`x' rxpv`x' rxxp`x' (mean) rxsf`x'_mean=rxsf`x' ///
        rxmr`x'_mean=rxmr`x' rxmd`x'_mean=rxmd`x' rxpv`x'_mean=rxpv`x' rxxp`x'_mean=rxxp`x' ///
       (first) perwt`f' rxname, by (dupersid rxndc)
       
      //to merge with MMS data
        gen year = `time'
      
        gen id2=_n
    
        drop if rxname=="-9" //drop all missing product name obs
    
        drop if real(substr(rxname,1,1))<. //drop all obs w product names starting with a number
    
        save "${output}\P`time'_dummy.dta", replace
        
        
    *************Combinig with the MMS dataset***********
    
    
        matchit id2 rxname using "${drug}\MMS_WAC_data.dta", idu(id1) txtu(Product)
        //1- matchit first by the most relevant pair of columns - drug name
    
        // 2- bring back the other columns
        joinby id1 using "${drug}\MMS_WAC_data.dta"
        joinby id2 using "${output}\P`time'_dummy.dta"
    
        save "${output}\`time'+MMS.dta", replace
      }
    Code:
    data sample
    
    input str8 DUPERSID str50 RXNAME str11 RXNDC double(RXSF07X RXMR07X RXMD07X RXPV07X RXXP07X PERWT07F)
    "60001029" "ALLOPURINOL"                   "00378018105"  10.48      0     0 0  10.48  4693.506405
    "60004013" "PREVACID"                      "00300304613"      0 175.01     0 0 175.01 14733.159185
    "60004013" "PREVACID"                      "00300304613"    3.1 138.48     0 0 141.58 14733.159185
    "60004013" "PREVACID"                      "00300304613"      0 169.26     0 0 169.26 14733.159185
    "60004013" "PREVACID"                      "00300304613"      0 175.01     0 0 175.01 14733.159185
    "60004013" "TOPROL XL"                     "00186109205"    3.1   32.6     0 0   35.7 14733.159185
    "60004013" "TOPROL XL"                     "00186109205"    3.1   32.6     0 0   35.7 14733.159185
    "60004013" "TOPROL XL"                     "00186109205"    3.1   32.6     0 0   35.7 14733.159185
    "60004013" "IMDUR"                         "54868435301"   2.15   1.85     0 0      4 14733.159185
    "60004013" "IMDUR"                         "54868435301"   2.15   1.85     0 0      4 14733.159185
    "60004013" "IMDUR"                         "54868435301"   2.15   1.85     0 0      4 14733.159185
    "60004013" "IMDUR"                         "54868435301"   2.15   1.85     0 0      4 14733.159185
    "60004013" "INSULIN"                       "59060231404"   3.43  82.77     0 0   86.2 14733.159185
    "60004013" "INSULIN"                       "59060231404"   5.24  80.96     0 0   86.2 14733.159185
    "60004013" "INSULIN"                       "59060231404"   5.62  80.58     0 0   86.2 14733.159185
    "60004013" "INSULIN"                       "59060231404"    1.8   84.4     0 0   86.2 14733.159185
    "60004013" "INSULIN"                       "59060231404"      0   86.2     0 0   86.2 14733.159185
    "60004020" "EXELON"                        "00078032444"      5 184.19     0 0 189.19 16364.385084
    "60004020" "EXELON"                        "00078032444" 187.05      0     0 0 187.05 16364.385084
    "60004020" "EXELON"                        "00078032444" 187.05      0     0 0 187.05 16364.385084
    "60004020" "SEROQUEL (FILM-COATED)"        "00310027510"      5  122.7     0 0  127.7 16364.385084

  • #2
    Code:
     
      rxsf`x'
    for example will get expanded to


    Code:
     
      rxsf07X 08X 09X 10X 11X 12X
    -- hence the error message. You want each suffix to be added repeatedly, but nothing in the syntax does that for you. It's a case of Stata doing what you say, not what you mean or what you want/

    Depending on your other variable names, a definition

    Code:
    local x ??X
    would possibly work to catch all the variable names you want, and no others, using a wildcard.

    Comment


    • #3
      Nick Cox Thank you, the wildcard approach worked perfectly. I do have another question however. My code fails at the line below with the message below it. I understand the code fails at the point where I am renaming the variables for the mean command in collapse, i.e. rxsf`x'_mean=rxsf`x' where `x' refers to the year in the local x. I know how to do this in just one dataset as seen with just the 2007 dataset below , but am unable to do it when running it in a loop on all datasets from 2007-2012. Any help, once again, will be much appreciated.

      Code:
      *Code fails at this line in the loop:
      
        //Data is in long form by id and drug code - collapsing on drug code  condl on id
        //calculating totals and averages by id and drug code
      
          collapse (sum) rxsf`x' rxmr`x' rxmd`x' rxpv`x' rxxp`x' (mean) rxsf`x'_mean=rxsf`x' ///
          rxmr`x'_mean=rxmr`x' rxmd`x'_mean=rxmd`x' rxpv`x'_mean=rxpv`x' rxxp`x'_mean=rxxp`x' ///
         (first) perwt`f' rxname, by (dupersid rxndc)
        
      ? invalid name
      ? invalid name
      r(7);
      Code:
      *The code successfully run on just the 2007 dataset
      
      collapse (sum) rxsf07x rxmr07x rxmd07x rxpv07x rxxp07x (mean) rxsf07x_mean=rxsf07x ///
      rxmr07x_mean=rxmr07x rxmd07x_mean=rxmd07x rxpv07x_mean=rxpv07x rxxp07x_mean=rxxp07x ///
      (first) perwt07f rxname, by (dupersid rxndc)
      Last edited by Scott Rick; 29 Jun 2021, 19:37. Reason: Adding the error number

      Comment


      • #4
        Having looked again at your problem and your code, I think I see where your code was ambitious and my code was not following the likely nature of your datasets. The trick, if I understand correctly, is not to calculate in advance what Stata can calculate on the fly.

        Further, neither your code nor mine adjusted your collapse syntax to account for your rename, You can't use the same suffix after lower-casing your names.

        Ignoring your local macros before the loop:


        Code:
        forval time = 2007/2012'{
            local t : di %02.0f mod(`time', 2000) 
            local X "`t'X" 
            local F "`t'F" 
            local x "`f'x" 
            local f "`t'f" 
        
            use "P`time'", clear
            keep DUPERSID RXNDC PERWT`F' RXSF`X' RXMR`X' RXMD`X' RXPV`X' RXXP`X' RXNAME
          
            rename *, lower 
            collapse (sum) rxsf`x' rxmr`x' rxmd`x' rxpv`x' rxxp`x' (mean) rxsf`x'_mean=rxsf`x' ///
            rxmr`x'_mean=rxmr`x' rxmd`x'_mean=rxmd`x' rxpv`x'_mean=rxpv`x' rxxp`x'_mean=rxxp`x' ///
           (first) perwt`f' rxname, by (dupersid rxndc)
        If, however, you have 2007 and 2008 data in the dataset for 2008, and so on, then this approach will fail and I will try again.

        See also https://www.stata-journal.com/articl...article=pr0051 (.pdf freely available).

        Comment


        • #5
          Nick Cox Hi Nick. Thanks. Unfortunately this didn't work. I ran the code as is and got the "invalid syntax" error. I suspected it was because the curly parenthesis wasn't closed and because there's an apostrophe in line 1 after 2007/2017. I closed parenthesis and removed the apostrophe to get the error "variable rxsfx not found". Below is the code that yields this error. I'm very close to running the code on each file independently, but believe that is inefficient and would really like to learn how to write this effectively.

          Thankfully, each dataset only carries data for that year, so that's one less problem to deal with!

          And thank you for the resource. It's great!

          Code:
          
          
          forval time = 2007/2012{
              local t : di %02.0f mod(`time', 2000) 
              local X "`t'X" 
              local F "`t'F" 
              local x "`f'x" 
              local f "`t'f" 
          
              use "P`time'", clear
          
              keep DUPERSID RXNDC PERWT`F' RXSF`X' RXMR`X' RXMD`X' RXPV`X' RXXP`X' RXNAME
            
              rename *, lower 
              collapse (sum) rxsf`x' rxmr`x' rxmd`x' rxpv`x' rxxp`x' (mean) rxsf`x'_mean=rxsf`x' ///
              rxmr`x'_mean=rxmr`x' rxmd`x'_mean=rxmd`x' rxpv`x'_mean=rxpv`x' rxxp`x'_mean=rxxp`x' ///
             (first) perwt`f' rxname, by (dupersid rxndc)
             
             //to merge with MMS data
              gen year = `time'
            
              gen id2=_n
          
              drop if rxname=="-9" //drop all missing product name obs
          
              drop if real(substr(rxname,1,1))<. //drop all obs w product names starting with a number
          
              save "${output}\P`time'_dummy.dta", replace
              
             }

          Comment


          • #6
            You found a typo of mine; sorry about that. Otherwise, sorry for a different reason: I can't test anything myself because I don't have your datasets.

            I suspect that your latest problem is because you are running code line by line and the collapse statement can't see the local macro definitions it refers to.

            Comment


            • #7
              Nick Cox I've attached below a sample of the datasets from 2007-2009. Would this help to test the code? I've also modified the code to cover 2007-2009 only. Thanks for all the help.

              Code:
              forval time = 2007/2009{
              
              local t : di %02.0f mod(`time', 2000)
              local X "`t'X"
              local F "`t'F"
              local x "`f'x" local f "`t'f"
              
              use "P`time'", clear
              
              keep DUPERSID RXNDC PERWT`F' RXSF`X' RXMR`X' RXMD`X' RXPV`X' RXXP`X' RXNAME
              
              rename *, lower
              
              collapse (sum) rxsf`x' rxmr`x' rxmd`x' rxpv`x' rxxp`x' (mean) rxsf`x'_mean=rxsf`x' /// rxmr`x'_mean=rxmr`x' rxmd`x'_mean=rxmd`x' rxpv`x'_mean=rxpv`x' rxxp`x'_mean=rxxp`x' /// (first) perwt`f' rxname, by (dupersid rxndc)
              
              //to merge with MMS data
              gen year = `time'
              
              gen id2=_n
              
              drop if rxname=="-9" //drop all missing product name obs
              
              drop if real(substr(rxname,1,1))<. //drop all obs w product names starting with a number
              
              save "${output}\P`time'_dummy.dta", replace
              }
              
              *20007 data
              
              clear
              input str8 DUPERSID str11 RXNDC double(PERWT07F RXSF07X RXMR07X RXMD07X RXPV07X RXXP07X) str50 RXNAME double(RXOU07X RXOR07X RXOT07X)
              "60001029" "00378018105" 4693.506405 10.48 0 0 0 10.48 "ALLOPURINOL" 0 0 0
              "60004013" "00300304613" 14733.159185 0 175.01 0 0 175.01 "PREVACID" 0 0 0
              "60004013" "00300304613" 14733.159185 3.1 138.48 0 0 141.58 "PREVACID" 0 0 0
              "60004013" "00300304613" 14733.159185 0 169.26 0 0 169.26 "PREVACID" 0 0 0
              "60004013" "00300304613" 14733.159185 0 175.01 0 0 175.01 "PREVACID" 0 0 0
              "60004013" "00186109205" 14733.159185 3.1 32.6 0 0 35.7 "TOPROL XL" 0 0 0
              "60004013" "00186109205" 14733.159185 3.1 32.6 0 0 35.7 "TOPROL XL" 0 0 0
              "60004013" "00186109205" 14733.159185 3.1 32.6 0 0 35.7 "TOPROL XL" 0 0 0
              "60004013" "54868435301" 14733.159185 2.15 1.85 0 0 4 "IMDUR" 0 0 0
              "60004013" "54868435301" 14733.159185 2.15 1.85 0 0 4 "IMDUR" 0 0 0
              "60004013" "54868435301" 14733.159185 2.15 1.85 0 0 4 "IMDUR" 0 0 0
              "60004013" "54868435301" 14733.159185 2.15 1.85 0 0 4 "IMDUR" 0 0 0
              "60004013" "59060231404" 14733.159185 3.43 82.77 0 0 86.2 "INSULIN" 0 0 0
              "60004013" "59060231404" 14733.159185 5.24 80.96 0 0 86.2 "INSULIN" 0 0 0
              "60004013" "59060231404" 14733.159185 5.62 80.58 0 0 86.2 "INSULIN" 0 0 0
              "60004013" "59060231404" 14733.159185 1.8 84.4 0 0 86.2 "INSULIN" 0 0 0
              "60004013" "59060231404" 14733.159185 0 86.2 0 0 86.2 "INSULIN" 0 0 0
              "60004020" "00078032444" 16364.385084 5 184.19 0 0 189.19 "EXELON" 0 0 0
              "60004020" "00078032444" 16364.385084 187.05 0 0 0 187.05 "EXELON" 0 0 0
              "60004020" "00078032444" 16364.385084 187.05 0 0 0 187.05 "EXELON" 0 0 0
              "60004020" "00310027510" 16364.385084 5 122.7 0 0 127.7 "SEROQUEL (FILM-COATED)" 0 0 0
              "60004020" "00310027510" 16364.385084 127.25 0 0 0 127.25 "SEROQUEL (FILM-COATED)" 0 0 0
              "60004020" "00310027510" 16364.385084 5 122.7 0 0 127.7 "SEROQUEL (FILM-COATED)" 0 0 0
              "60007011" "62794014610" 5151.10749 4 0 0 0 4 "DIGITEK" 0 0 0
              "60007011" "62794014610" 5151.10749 4 0 0 0 4 "DIGITEK" 0 0 0
              "60007011" "62794014610" 5151.10749 4 0 0 0 4 "DIGITEK" 0 0 0
              "60007011" "63304079130" 5151.10749 23.92 0 0 0 23.92 "SIMVASTATIN (USP,UNIT OF USE)" 0 0 0
              "60007011" "63304079130" 5151.10749 23.92 0 0 0 23.92 "SIMVASTATIN (USP,UNIT OF USE)" 0 0 0
              "60007011" "63304079130" 5151.10749 23.92 0 0 0 23.92 "SIMVASTATIN (USP,UNIT OF USE)" 0 0 0
              "60007011" "62037070030" 5151.10749 32.64 0 0 0 32.64 "TAZTIA XT" 0 0 0
              "60007011" "62037070030" 5151.10749 32.64 0 0 0 32.64 "TAZTIA XT" 0 0 0
              "60007011" "62037070030" 5151.10749 32.64 0 0 0 32.64 "TAZTIA XT" 0 0 0
              "60007011" "00054474225" 5151.10749 2.15 0 0 0 2.15 "PREDNISONE" 0 0 0
              "60007011" "00054474225" 5151.10749 2.15 0 0 0 2.15 "PREDNISONE" 0 0 0
              "60007011" "00054474225" 5151.10749 2.15 0 0 0 2.15 "PREDNISONE" 0 0 0
              "60007011" "00781207401" 5151.10749 4 0 0 0 4 "HCTZ/TRIAMTERENE" 0 0 0
              "60007011" "00781207401" 5151.10749 4 0 0 0 4 "HCTZ/TRIAMTERENE" 0 0 0
              "60007011" "00781207401" 5151.10749 4 0 0 0 4 "HCTZ/TRIAMTERENE" 0 0 0
              "60007011" "62794014610" 5151.10749 4 0 0 0 4 "DIGITEK" 0 0 0
              "60007011" "62794014610" 5151.10749 4 0 0 0 4 "DIGITEK" 0 0 0
              "60007011" "62794014610" 5151.10749 4 0 0 0 4 "DIGITEK" 0 0 0
              "60007011" "62794014610" 5151.10749 4 0 0 0 4 "DIGITEK" 0 0 0
              "60007011" "63304079190" 5151.10749 56 0 0 0 56 "SIMVASTATIN (USP,FILM COATED)" 0 0 0
              "60007011" "63304079190" 5151.10749 56 0 0 0 56 "SIMVASTATIN (USP,FILM COATED)" 0 0 0
              "60007011" "63304079190" 5151.10749 56 0 0 0 56 "SIMVASTATIN (USP,FILM COATED)" 0 0 0
              "60007011" "63304079190" 5151.10749 56 0 0 0 56 "SIMVASTATIN (USP,FILM COATED)" 0 0 0
              "60007011" "62037070030" 5151.10749 32.5 0 0 0 32.5 "TAZTIA XT" 0 0 0
              "60007011" "62037070030" 5151.10749 32.5 0 0 0 32.5 "TAZTIA XT" 0 0 0
              "60007011" "62037070030" 5151.10749 32.5 0 0 0 32.5 "TAZTIA XT" 0 0 0
              "60007011" "62037070030" 5151.10749 32.5 0 0 0 32.5 "TAZTIA XT" 0 0 0
              "60007011" "00054474225" 5151.10749 2.15 0 0 0 2.15 "PREDNISONE" 0 0 0
              "60007011" "00054474225" 5151.10749 2.15 0 0 0 2.15 "PREDNISONE" 0 0 0
              "60007011" "00054474225" 5151.10749 2.15 0 0 0 2.15 "PREDNISONE" 0 0 0
              "60007011" "00054474225" 5151.10749 2.15 0 0 0 2.15 "PREDNISONE" 0 0 0
              "60007011" "00781207401" 5151.10749 4 0 0 0 4 "HCTZ/TRIAMTERENE" 0 0 0
              "60007011" "00781207401" 5151.10749 4 0 0 0 4 "HCTZ/TRIAMTERENE" 0 0 0
              "60007011" "00781207401" 5151.10749 4 0 0 0 4 "HCTZ/TRIAMTERENE" 0 0 0
              "60007011" "00781207401" 5151.10749 4 0 0 0 4 "HCTZ/TRIAMTERENE" 0 0 0
              "60007011" "62794014610" 5151.10749 4 0 0 0 4 "DIGITEK" 0 0 0
              "60007011" "62794014610" 5151.10749 4 0 0 0 4 "DIGITEK" 0 0 0
              "60007011" "62794014610" 5151.10749 4 0 0 0 4 "DIGITEK" 0 0 0
              "60007011" "62794014610" 5151.10749 4 0 0 0 4 "DIGITEK" 0 0 0
              "60007011" "63304079190" 5151.10749 56 0 0 0 56 "SIMVASTATIN (USP,FILM COATED)" 0 0 0
              "60007011" "63304079190" 5151.10749 56 0 0 0 56 "SIMVASTATIN (USP,FILM COATED)" 0 0 0
              "60007011" "63304079190" 5151.10749 56 0 0 0 56 "SIMVASTATIN (USP,FILM COATED)" 0 0 0
              "60007011" "63304079190" 5151.10749 56 0 0 0 56 "SIMVASTATIN (USP,FILM COATED)" 0 0 0
              
              
              *2008 data
              
              dataex DUPERSID RXNDC PERWT08F RXSF08X RXMR08X RXMD08X RXPV08X RXXP08X RXNAME RXOU08X RXOR08X RXOT
              > 08X
              
              * Example generated by -dataex-. To install: ssc install dataex
              clear
              input str8 DUPERSID str11 RXNDC double(PERWT08F RXSF08X RXMR08X RXMD08X RXPV08X RXXP08X) str50 RXNAME double(RXOU08X RXOR08X RXOT08X)
              "70001102" "00781140301"  9710.367566    20     0      0      0     20 "LORAZEPAM"                                      0 0 0
              "70001102" "00172531260"  9710.367566  5.71     0      0  16.88  22.59 "CIPROFLOXACIN (FILM-COATED)"                    0 0 0
              "70001104" "00093310905"  7707.102248  5.14     0      0      0   5.14 "AMOXICILLIN"                                    0 0 0
              "70004102" "63304097904" 12498.277493    21     0      0      0     21 "AMOXICILLIN/CLAVULANATE POTASSIUM (STRAWBERRY)" 0 0 0
              "70004102" "00247118140" 12498.277493 44.05     0      0      0  44.05 "KEFLEX"                                         0 0 0
              "70004102" "17478071110" 12498.277493 29.73     0      0      0  29.73 "LIDOCAINE JELLY"                                0 0 0
              "70004103" "00029604954" 10963.228493     8     0      0      0      8 "AMOXIL (BUBBLEGUM)"                             0 0 0
              "70008201" "00029152722"  5212.692404     0     0  40.74      0  40.74 "BACTROBAN"                                      0 0 0
              "70008201" "00029152722"  5212.692404     0     0  40.74      0  40.74 "BACTROBAN"                                      0 0 0
              "70008201" "51672129203"  5212.692404     0     0  27.98      0  27.98 "HYDROCORTISONE VALERATE"                        0 0 0
              "70008201" "51672129203"  5212.692404     0     0  27.98      0  27.98 "HYDROCORTISONE VALERATE"                        0 0 0
              "70009101" "00378521077"  6866.933553    10  4.04      0      0  14.04 "AMLODIPINE BESYLATE"                            0 0 0
              "70009101" "51991046810"  6866.933553    10     6      0      0     16 "CYCLOBENZAPRINE HYDROCHLORIDE (FILM-COATED)"    0 0 0
              "70009101" "00093725201"  6866.933553    10 45.84      0      0  55.84 "FEXOFENADINE HCL (FILM-COATED)"                 0 0 0
              "70009101" "60505017300"  6866.933553    10     0      0    1.8   11.8 "QUINAPRIL (USP,FILM COATED)"                    0 0 0
              "70009101" "00186504031"  6866.933553    25     0      0  123.8  148.8 "NEXIUM (UNIT OF USE)"                           0 0 0
              "70009101" "60505017300"  6866.933553    10     0      0    1.8   11.8 "QUINAPRIL (USP,FILM COATED)"                    0 0 0
              "70009101" "60505017300"  6866.933553    10     0      0    1.8   11.8 "QUINAPRIL (USP,FILM COATED)"                    0 0 0
              "70009101" "60505017300"  6866.933553    10     0      0    1.8   11.8 "QUINAPRIL (USP,FILM COATED)"                    0 0 0
              "70009101" "60505017300"  6866.933553    10     0      0    1.8   11.8 "QUINAPRIL (USP,FILM COATED)"                    0 0 0
              "70009101" "59762502001"  6866.933553    10     0      0   1.78  11.78 "QUINAPRIL HCL (FILM-COATED)"                    0 0 0
              "70009101" "59762502001"  6866.933553    10     0      0   1.78  11.78 "QUINAPRIL HCL (FILM-COATED)"                    0 0 0
              "70009101" "37205032730"  6866.933553     0     0  11.39      0  11.39 "SORE THROAT (AF,SF,CHERRY)"                     0 0 0
              "70009101" "37205032730"  6866.933553     0     0  11.39      0  11.39 "SORE THROAT (AF,SF,CHERRY)"                     0 0 0
              "70009101" "37205032730"  6866.933553     0     0  11.39      0  11.39 "SORE THROAT (AF,SF,CHERRY)"                     0 0 0
              "70009101" "37205032730"  6866.933553     0     0  11.39      0  11.39 "SORE THROAT (AF,SF,CHERRY)"                     0 0 0
              "70009101" "37205032730"  6866.933553     0     0  11.39      0  11.39 "SORE THROAT (AF,SF,CHERRY)"                     0 0 0
              "70009101" "37205032730"  6866.933553     0     0  11.39      0  11.39 "SORE THROAT (AF,SF,CHERRY)"                     0 0 0
              "70009101" "00186504031"  6866.933553    25     0      0  123.8  148.8 "NEXIUM (UNIT OF USE)"                           0 0 0
              "70009101" "00186504031"  6866.933553    25     0      0  123.8  148.8 "NEXIUM (UNIT OF USE)"                           0 0 0
              
              
              *2009 data
              
              clear
              input str8 DUPERSID str11 RXNDC double(PERWT09F RXSF09X RXMR09X RXMD09X RXPV09X RXXP09X) str50 RXNAME double(RXOU09X RXOR09X RXOT09X)
              "40001101" "87701053738" 14251.111105      9     11     0      0     20 "MOUTHWASH"                        0 0 0
              "40001101" "00173069600" 14251.111105  25.55 175.14     0      0 200.69 "ADVAIR DISKUS"                    0 0 0
              "40001101" "51672125902" 14251.111105      5   2.25     0      0   7.25 "CLOBETASOL PROPIONATE"            0 0 0
              "40001101" "00173069600" 14251.111105     20 396.17     0      0 416.17 "ADVAIR DISKUS"                    0 0 0
              "40001102" "00555905058" 15534.617101     10  35.99     0      0  45.99 "KARIVA"                           0 0 0
              "40001102" "00555905058" 15534.617101  15.46  30.53     0      0  45.99 "KARIVA"                           0 0 0
              "40001102" "00555905058" 15534.617101     15  30.99     0      0  45.99 "KARIVA"                           0 0 0
              "40001102" "65162066810" 15534.617101      0   5.08     0      0   5.08 "PRENATAL PLUS"                    0 0 0
              "40001102" "00069307075" 15534.617101     15      0     0      6     21 "ZITHROMAX"                        0 0 0
              "40001102" "00781149631" 15534.617101     10      0     0      9     19 "AZITHROMYCIN"                     0 0 0
              "40001102" "00603578128" 15534.617101     10      0     0      0     10 "SULFAMETHOXAZOLE-TRIMETHOPRIM DS" 0 0 0
              "40001102" "65162066810" 15534.617101   5.08      0     0      0   5.08 "PRENATAL PLUS"                    0 0 0
              "40001103" "00093867575" 14803.089514      5  28.11     0      0  33.11 "AMOXICILLIN-CLAVULANATE"          0 0 0
              "40001103" "00186198904" 14803.089514 418.72      0     0      0 418.72 "PULMICORT RESPULES"               0 0 0
              "40001103" "00186198904" 14803.089514     20 398.72     0      0 418.72 "PULMICORT RESPULES"               0 0 0
              "40001103" "00186198904" 14803.089514 183.75 234.97     0      0 418.72 "PULMICORT RESPULES"               0 0 0
              "40001103" "00093867575" 14803.089514      5  28.11     0      0  33.11 "AMOXICILLIN-CLAVULANATE"          0 0 0
              "40001103" "00603702073" 14803.089514   3.34      0     0      0   3.34 "A/B OTIC"                         0 0 0
              "40001103" "00093413773" 14803.089514      5  89.98     0      0  94.98 "CEFDINIR"                         0 0 0
              "40001103" "00093412774" 14803.089514   4.72      0     0      0   4.72 "PENICILLIN V POTASSIUM"           0 0 0
              "40001103" "00093416173" 14803.089514    6.1      0     0      0    6.1 "AMOXICILLIN"                      0 0 0
              "40002101" "68180051403"  4391.466216     10      0     0      0     10 "LISINOPRIL"                       0 0 0
              "40002101" "68180051403"  4391.466216     10      0     0      0     10 "LISINOPRIL"                       0 0 0
              "40003101" "00116200116"  3570.185247    1.4      0     0   5.59   6.99 "CHLORHEXIDINE GLUCONATE"          0 0 0
              "40003101" "00116200116"  3570.185247    1.4      0     0   5.59   6.99 "CHLORHEXIDINE GLUCONATE"          0 0 0
              "40003102" "00069154068"   3044.07282      0      0     0      0      6 "NORVASC"                          0 0 0
              "40003102" "31722023990"   3044.07282     15      0     0      0     15 "AMLODIPINE BESYLATE"              0 0 0
              "40003102" "31722023990"   3044.07282     15      0     0      0     15 "AMLODIPINE BESYLATE"              0 0 0
              "40003102" "31722023990"   3044.07282     15      0     0      0     15 "AMLODIPINE BESYLATE"              0 0 0
              "40003102" "31722023990"   3044.07282     15      0     0      0     15 "AMLODIPINE BESYLATE"              0 0 0
              "40003102" "31722023990"   3044.07282     15      0     0      0     15 "AMLODIPINE BESYLATE"              0 0 0
              "40003102" "31722023990"   3044.07282     15      0     0      0     15 "AMLODIPINE BESYLATE"              0 0 0
              "40003102" "31722023990"   3044.07282     15      0     0      0     15 "AMLODIPINE BESYLATE"              0 0 0
              "40005101" "00186504082" 10719.253207     85      0     0 361.62 446.62 "NEXIUM"                           0 0 0
              "40005101" "00186504082" 10719.253207     85      0     0 361.62 446.62 "NEXIUM"                           0 0 0
              "40005102" "00004018682" 10346.301591     50      0     0     55    105 "BONIVA"                           0 0 0
              "40005102" "66582031354" 10346.301591  19.41      0     0  77.46  96.87 "VYTORIN"                          0 0 0
              "40005102" "00006074731" 10346.301591     40      0     0   52.8   92.8 "HYZAAR"                           0 0 0
              "40005102" "60598000101" 10346.301591     20      0     0    106    126 "NIASPAN"                          0 0 0
              "40005102" "66582031331" 10346.301591    125      0     0 145.33 270.33 "VYTORIN"                          0 0 0
              "40005102" "66582031331" 10346.301591    125      0     0 145.33 270.33 "VYTORIN"                          0 0 0
              "40005102" "00006074731" 10346.301591     40      0     0   52.8   92.8 "HYZAAR"                           0 0 0
              "40005102" "00006074731" 10346.301591     40      0     0   52.8   92.8 "HYZAAR"                           0 0 0
              "40005102" "60598000101" 10346.301591     20      0     0    106    126 "NIASPAN"                          0 0 0
              "40005102" "60598000101" 10346.301591     20      0     0    106    126 "NIASPAN"                          0 0 0
              "40005102" "00004018682" 10346.301591     50      0     0     47     97 "BONIVA"                           0 0 0
              "40005102" "00004018682" 10346.301591     50      0     0     55    105 "BONIVA"                           0 0 0
              "40005102" "00004018682" 10346.301591     50      0     0     47     97 "BONIVA"                           0 0 0
              "40005102" "00006074731" 10346.301591     40      0     0   52.8   92.8 "HYZAAR"                           0 0 0
              "40005102" "60598000101" 10346.301591     20      0     0    106    126 "NIASPAN"                          0 0 0
              "40005102" "63304079390" 10346.301591      7      0     0      0      7 "SIMVASTATIN"                      0 0 0
              "40005103" "00378207401" 12628.881027     10      0     0      0     10 "LISINOPRIL"                       0 0 0
              Last edited by Scott Rick; 30 Jun 2021, 12:52.

              Comment


              • #8
                One typo each, I think.

                Code:
                local X "`t'X"
                local F "`t'F"
                local x "`f'x" local f "`t'f"
                should be

                Code:
                local X "`t'X"
                local F "`t'F"
                local x "`t'x"  
                local f "`t'f"

                Comment


                • #9
                  Thanks, Nick. That worked perfectly!

                  Comment

                  Working...
                  X