Announcement

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

  • Postfile

    Hi all, I have had no luck with my research as I have been unable to loop these commands properly as my postfile wont work - if anyone would be able to tell me what was failing please let me know - *Generate helper variable
    gen ipc3 = substr(ipc4, 1, 3)
    gen country = substr(nuts3, 1, 2)
    gen ipc2 = substr(ipc4, 1, 2)
    *Sum patents by country-region-year
    collapse (sum) sh_pat, by(country nuts3 ipc2 year)
    *Total patents per country-year
    bysort country ipc2 year: egen tot_pat_cpt = total(sh_pat)
    *Region share of tp (within country-year)
    gen share_region = sh_pat / tot_pat_cpt
    egen cod_tech=group(country ipc2)



    * STEP 2: Theil and Gini Indices
    preserve
    tempfile tgresults
    tempname tgpost
    postfile `tgpost' double cod_tech int year double theil gini using `tgresults', replace

    levelsof cod_tech, local(countries)
    levelsof year, local(years)


    foreach c of local countries {
    foreach y of local years {
    keep if cod_tech == `c' & year == `y'
    qui count if share_region > 0
    if r(N) >= 2 {
    qui ineqdeco share_region
    local gini = r(gini)
    local theil = r(ge1)
    }
    else {
    local gini = .
    local theil = .
    }
    post `tgpost' (`c') (`y') (`theil') (`gini')
    restore, preserve
    }
    }

    postclose `tgpost'
    use `tgresults', clear
    save theil_gini_cod_tech.dta, replace
    restore


    it returns the following error wrt the postfile failure - [P] error . . . . . . . . . . . . . . . . . . . . . . . . Return code 198
    invalid syntax
    option __________ incorrectly specified
    option __________ not allowed
    __________ invalid
    range invalid
    __________ invalid obs no
    invalid filename
    __________ invalid varname
    __________ invalid name
    multiple by's not allowed
    __________ found where number expected
    on or off required
    All items in this list indicate invalid syntax. These errors
    are often, but not always, due to typographical errors. Stata
    attempts to provide you with as much information as it can.
    Review the syntax diagram for the designated command.

    In giving the message "invalid syntax", Stata is not helpful.
    Errors in specifying expressions often result in this message.

    (end of search)

  • #2
    A quick suggestion here would be to use -set trace on- so as to better reveal exactly what the problem syntax looks like at runtime. Perhaps you know exactly where the problem is occurring, but I wouldn't be certain from what you have posted. If you haven't used -set trace- before, you'll find its output large and possibly intimidating, but it should be possible to find the exact problem area and what it looks like. If you can do this and post back here, that might help you get a helpful answer sooner.

    Comment


    • #3
      Thank you very much for the advice, Mike. I’ve tried to implement it in the above do-file. While it no longer returns a syntax error, it now results in no observations—which I suppose is progress, but I’m still a bit stuck. Do you have any further suggestions?

      Comment


      • #4
        Adam, I'm afraid your problem description is far too vague ("my postfix wont work") and you do not provide a data extract either for us to be able got replicate your issue. Please read the forum FAQ on how to post more effective questions, especially tip #12, and act on those suggestions. Otherwise it is unlikely anyone will be able to help you.

        Comment


        • #5
          Thank you, Hemanshu. I will try again, having read this

          Comment


          • #6
            I’ve been trying to loop over combinations of region and year to compute Theil and Gini indices using the `ineqdeco` command from SSC. I’m using Stata 18.1 on Windows. The problem I’m running into is that the loop runs without error, but the output dataset created by `postfile` remains empty.

            After turning on `set trace on`, it seems that the `post` line is not being executed for many iterations. From what I can tell, the issue may be with how I’m using `preserve`/`restore` in combination with `keep`, or that the condition for posting is never satisfied due to too few observations after filtering.

            Here is a simplified and reproducible example of my code structure:

            ```stata
            * Generate helper variables
            gen ipc3 = substr(ipc4, 1, 3)
            gen ipc2 = substr(ipc4, 1, 2)
            gen country = substr(nuts3, 1, 2)

            * Collapse to regional totals
            collapse (sum) sh_pat, by(country nuts3 ipc2 year)
            bysort country ipc2 year: egen tot_pat_cpt = total(sh_pat)
            gen share_region = sh_pat / tot_pat_cpt
            egen cod_tech = group(country ipc2)

            * Loop setup
            preserve
            tempfile tgresults
            tempname tgpost
            postfile `tgpost' double cod_tech int year double theil gini using `tgresults', replace

            levelsof cod_tech, local(countries)
            levelsof year, local(years)

            foreach c of local countries {
            foreach y of local years {
            keep if cod_tech == `c' & year == `y'
            qui count if share_region > 0
            if r(N) >= 2 {
            qui ineqdeco share_region
            local gini = r(gini)
            local theil = r(ge1)
            }
            else {
            local gini = .
            local theil = .
            }
            post `tgpost' (`c') (`y') (`theil') (`gini')
            restore, preserve
            }
            }

            postclose `tgpost'
            use `tgresults', clear
            save theil_gini_cod_tech.dta, replace
            restore



            My questions are:

            Is the restore, preserve pattern inside a nested loop like this known to cause issues?

            Is there a better way to structure this to avoid accidentally skipping the post command due to the keep filter?

            Would it be better to use a loop over a pre-generated list of unique (cod_tech, year) pairs?

            I suspect many combinations of cod_tech and year have fewer than two regions with non-zero shares, and so the post line is skipped — but I’d like to know the best-practice way to handle this kind of filtering and looping with postfile.

            Unfortunately, I can't post my full dataset, but I can generate a small fake example with dataex if needed.

            Thanks very much for your time and suggestions.

            Best,
            Adam

            Comment


            • #7
              For what it's worth, Adam, I created a fake dataset to see if I can replicate your problem. And it seems to work just fine with your code in #1.

              Here is the fake data:

              Code:
              clear
              input str5 nuts3 int year str4 ipc4 float sh_pat
              "BE211" 2020 "ABCD" 197
              "BE211" 2021 "ABCD" 202
              "BE211" 2022 "ABCD" 163
              "BE211" 2023 "ABCD" 194
              "BE211" 2024 "ABCD" 186
              "BE211" 2025 "ABCD" 198
              "BE213" 2020 "ABCD" 207
              "BE213" 2021 "ABCD" 189
              "BE213" 2022 "ABCD" 181
              "BE213" 2023 "ABCD" 206
              "BE213" 2024 "ABCD" 198
              "BE213" 2025 "ABCD" 176
              "FRJ22" 2020 "ABCD" 173
              "FRJ22" 2021 "ABCD" 197
              "FRJ22" 2022 "ABCD" 199
              "FRJ22" 2023 "ABCD" 198
              "FRJ22" 2024 "ABCD" 227
              "FRJ22" 2025 "ABCD" 191
              "FRK14" 2020 "ABCD" 209
              "FRK14" 2021 "ABCD" 217
              "FRK14" 2022 "ABCD" 207
              "FRK14" 2023 "ABCD" 223
              "FRK14" 2024 "ABCD" 192
              "FRK14" 2025 "ABCD" 194
              "BE211" 2020 "EFGH" 228
              "BE211" 2021 "EFGH" 206
              "BE211" 2022 "EFGH" 192
              "BE211" 2023 "EFGH" 197
              "BE211" 2024 "EFGH" 219
              "BE211" 2025 "EFGH" 207
              "BE213" 2020 "EFGH" 178
              "BE213" 2021 "EFGH" 199
              "BE213" 2022 "EFGH" 204
              "BE213" 2023 "EFGH" 206
              "BE213" 2024 "EFGH" 195
              "BE213" 2025 "EFGH" 210
              "FRJ22" 2020 "EFGH" 201
              "FRJ22" 2021 "EFGH" 202
              "FRJ22" 2022 "EFGH" 184
              "FRJ22" 2023 "EFGH" 204
              "FRJ22" 2024 "EFGH" 216
              "FRJ22" 2025 "EFGH" 196
              "FRK14" 2020 "EFGH" 220
              "FRK14" 2021 "EFGH" 196
              "FRK14" 2022 "EFGH" 195
              "FRK14" 2023 "EFGH" 189
              "FRK14" 2024 "EFGH" 202
              "FRK14" 2025 "EFGH" 180
              end
              and here are the contents of the resulting theil_gini_cod_tech.dta file:
              Code:
              . list, noobs sepby(cod_tech)
              
                +----------------------------------------+
                | cod_tech   year       theil       gini |
                |----------------------------------------|
                |        1   2020   .00030637   .0123762 |
                |        1   2021   .00055282    .016624 |
                |        1   2022   .00136961   .0261628 |
                |        1   2023   .00045007       .015 |
                |        1   2024   .00048836    .015625 |
                |        1   2025    .0017311   .0294118 |
                |----------------------------------------|
                |        2   2020   .00760258   .0615764 |
                |        2   2021   .00014937    .008642 |
                |        2   2022   .00045921   .0151515 |
                |        2   2023   .00024939   .0111663 |
                |        2   2024   .00168126   .0289855 |
                |        2   2025   .00002588   .0035971 |
                |----------------------------------------|
                |        3   2020   .00444726   .0471204 |
                |        3   2021   .00116734   .0241546 |
                |        3   2022   .00019415   .0098522 |
                |        3   2023   .00176417   .0296912 |
                |        3   2024   .00349288   .0417661 |
                |        3   2025   .00003036   .0038961 |
                |----------------------------------------|
                |        4   2020   .00101873   .0225653 |
                |        4   2021   .00011364   .0075377 |
                |        4   2022   .00042125   .0145119 |
                |        4   2023   .00072857    .019084 |
                |        4   2024   .00056099   .0167464 |
                |        4   2025   .00090566   .0212766 |
                +----------------------------------------+

              Comment


              • #8
                I don't think your preserve, restore is causing a problem. That said, I also don't think you need to preserve and restore repeatedly. Why not just put in if conditions as needed? For instance, the code in #1 for your second step could be modified to
                Code:
                * STEP 2: Theil and Gini Indices
                tempfile tgresults
                tempname tgpost
                postfile `tgpost' double cod_tech int year double theil gini using `tgresults', replace
                
                levelsof cod_tech, local(countries)
                levelsof year, local(years)
                
                    foreach c of local countries {
                        foreach y of local years {
                            local if_cond cod_tech == `c' & year == `y'
                            qui count if `if_cond' & share_region > 0
                            if r(N) >= 2 {
                                qui ineqdeco share_region if `if_cond'
                                local gini = r(gini)
                                local theil = r(ge1)
                            }
                            else {
                                local gini = .
                                local theil = .
                            }
                            post `tgpost' (`c') (`y') (`theil') (`gini')
                        }
                    }
                
                    postclose `tgpost'
                    use `tgresults', clear
                    save theil_gini_cod_tech.dta, replace

                Comment


                • #9
                  I suspect many combinations of cod_tech and year have fewer than two regions with non-zero shares, and so the post line is skipped — but I’d like to know the best-practice way to handle this kind of filtering and looping with postfile.
                  Since I wasn't able to replicate your problem, could you edit the fake data I provided in #7 (or create your own) to show us a situation where the problem occurs?

                  Comment


                  • #10
                    I really appreciate all your help with this — thank you! I have tried to run your revised code, and, unfortunately, no results persist.

                    I’ve now run dataex on the relevant dataset and received the following output. It includes cod_tech, year, and share_region, and should replicate the issue I’ve been facing (i.e., no results being posted, possibly due to filtering conditions like r(N) < 2):

                    Code:
                    • Example generated by -dataex-. For more info, type help dataex clear input str5 nuts3 int year str2(ipc2 country) double sh_pat float(tot_pat_cpt share_region cod_tech) ... end
                    If anything looks off or you’d recommend modifying how I structured the data or posted the results, I’d be very grateful for your thoughts!
                    Code:
                    * Example generated by -dataex-. For more info, type help dataex
                    clear
                    input str5 nuts3 int year str2(ipc2 country) double sh_pat float(tot_pat_cpt share_region cod_tech)
                    "AT335" 1990 "A0" "AT"  1.3333333432674408 9.888889  .13483146 1
                    "AT125" 1990 "A0" "AT"                   0 9.888889          0 1
                    "AT313" 1990 "A0" "AT"                   0 9.888889          0 1
                    "AT130" 1990 "A0" "AT"                   0 9.888889          0 1
                    "AT323" 1990 "A0" "AT"                   0 9.888889          0 1
                    "AT121" 1990 "A0" "AT"   2.092592593282461 9.888889   .2116105 1
                    "AT341" 1990 "A0" "AT"                   0 9.888889          0 1
                    "AT222" 1990 "A0" "AT"                   0 9.888889          0 1
                    "AT111" 1990 "A0" "AT"                   0 9.888889          0 1
                    "AT126" 1990 "A0" "AT"                   0 9.888889          0 1
                    "AT122" 1990 "A0" "AT"                   0 9.888889          0 1
                    "AT212" 1990 "A0" "AT"                   0 9.888889          0 1
                    "AT314" 1990 "A0" "AT"                   0 9.888889          0 1
                    "AT331" 1990 "A0" "AT"                   0 9.888889          0 1
                    "AT223" 1990 "A0" "AT"                   0 9.888889          0 1
                    "AT224" 1990 "A0" "AT"                   0 9.888889          0 1
                    "AT334" 1990 "A0" "AT"                   0 9.888889          0 1
                    "AT315" 1990 "A0" "AT"                   0 9.888889          0 1
                    "AT312" 1990 "A0" "AT"  1.9629629850387573 9.888889  .19850187 1
                    "AT127" 1990 "A0" "AT"                   0 9.888889          0 1
                    "AT322" 1990 "A0" "AT"                   0 9.888889          0 1
                    "AT225" 1990 "A0" "AT"                   0 9.888889          0 1
                    "AT342" 1990 "A0" "AT"                   0 9.888889          0 1
                    "AT226" 1990 "A0" "AT"                   0 9.888889          0 1
                    "AT332" 1990 "A0" "AT"                   0 9.888889          0 1
                    "AT221" 1990 "A0" "AT"                   1 9.888889   .1011236 1
                    "AT213" 1990 "A0" "AT"                   0 9.888889          0 1
                    "AT124" 1990 "A0" "AT"                   0 9.888889          0 1
                    "AT311" 1990 "A0" "AT"                 3.5 9.888889   .3539326 1
                    "AT211" 1990 "A0" "AT"                   0 9.888889          0 1
                    "AT112" 1990 "A0" "AT"                   0 9.888889          0 1
                    "AT123" 1990 "A0" "AT"                   0 9.888889          0 1
                    "AT124" 1991 "A0" "AT"                   0 9.986743          0 1
                    "AT130" 1991 "A0" "AT"  1.1666666716337204 9.986743  .11682153 1
                    "AT313" 1991 "A0" "AT"                   0 9.986743          0 1
                    "AT226" 1991 "A0" "AT"                   0 9.986743          0 1
                    "AT333" 1991 "A0" "AT"                   0 9.986743          0 1
                    "AT314" 1991 "A0" "AT"                   1 9.986743  .10013275 1
                    "AT223" 1991 "A0" "AT"                   1 9.986743  .10013275 1
                    "AT126" 1991 "A0" "AT"                   0 9.986743          0 1
                    "AT311" 1991 "A0" "AT"   3.166666693985462 9.986743    .317087 1
                    "AT125" 1991 "A0" "AT"                   0 9.986743          0 1
                    "AT113" 1991 "A0" "AT"                   0 9.986743          0 1
                    "AT335" 1991 "A0" "AT"  .09090909361839294 9.986743 .009102977 1
                    "AT341" 1991 "A0" "AT"                   0 9.986743          0 1
                    "AT334" 1991 "A0" "AT"                   0 9.986743          0 1
                    "AT332" 1991 "A0" "AT"                   0 9.986743          0 1
                    "AT315" 1991 "A0" "AT"   .6666666865348816 9.986743  .06675517 1
                    "AT123" 1991 "A0" "AT"                   0 9.986743          0 1
                    "ATZZZ" 1991 "A0" "AT"                   0 9.986743          0 1
                    "AT331" 1991 "A0" "AT"                   0 9.986743          0 1
                    "AT121" 1991 "A0" "AT"  1.0000000298023224 9.986743  .10013275 1
                    "AT127" 1991 "A0" "AT"   .1666666716337204 9.986743 .016688792 1
                    "AT323" 1991 "A0" "AT"                   0 9.986743          0 1
                    "AT221" 1991 "A0" "AT"   .1041666679084301 9.986743 .010430494 1
                    "AT112" 1991 "A0" "AT"                   0 9.986743          0 1
                    "AT222" 1991 "A0" "AT"                   0 9.986743          0 1
                    "AT342" 1991 "A0" "AT"                   0 9.986743          0 1
                    "AT212" 1991 "A0" "AT"                   0 9.986743          0 1
                    "AT122" 1991 "A0" "AT"                   0 9.986743          0 1
                    "AT211" 1991 "A0" "AT"                   0 9.986743          0 1
                    "AT312" 1991 "A0" "AT"  1.6250000074505806 9.986743   .1627157 1
                    "AT225" 1991 "A0" "AT"                   0 9.986743          0 1
                    "AT322" 1991 "A0" "AT"                   0 9.986743          0 1
                    "AT224" 1991 "A0" "AT"                   0 9.986743          0 1
                    "AT213" 1991 "A0" "AT"                   0 9.986743          0 1
                    "AT334" 1992 "A0" "AT"                   0 6.836905          0 1
                    "AT312" 1992 "A0" "AT"  1.7448979765176773 6.836905  .25521752 1
                    "AT130" 1992 "A0" "AT"  .20000000298023224 6.836905    .029253 1
                    "AT123" 1992 "A0" "AT"                   0 6.836905          0 1
                    "AT322" 1992 "A0" "AT"                   1 6.836905  .14626502 1
                    "AT315" 1992 "A0" "AT"                   0 6.836905          0 1
                    "AT342" 1992 "A0" "AT"                   0 6.836905          0 1
                    "AT112" 1992 "A0" "AT"                   0 6.836905          0 1
                    "AT222" 1992 "A0" "AT"                   0 6.836905          0 1
                    "AT313" 1992 "A0" "AT"                   0 6.836905          0 1
                    "AT113" 1992 "A0" "AT"                   0 6.836905          0 1
                    "AT341" 1992 "A0" "AT"                   0 6.836905          0 1
                    "AT213" 1992 "A0" "AT"                   0 6.836905          0 1
                    "AT323" 1992 "A0" "AT"  1.3333333432674408 6.836905     .19502 1
                    "AT223" 1992 "A0" "AT"                   0 6.836905          0 1
                    "AT335" 1992 "A0" "AT"                   0 6.836905          0 1
                    "AT125" 1992 "A0" "AT"                   0 6.836905          0 1
                    "AT311" 1992 "A0" "AT"                 1.5 6.836905   .2193975 1
                    "AT126" 1992 "A0" "AT"                   0 6.836905          0 1
                    "AT332" 1992 "A0" "AT"                   0 6.836905          0 1
                    "AT331" 1992 "A0" "AT"                   0 6.836905          0 1
                    "ATZZZ" 1992 "A0" "AT"                   0 6.836905          0 1
                    "AT221" 1992 "A0" "AT"  .01785714365541935 6.836905 .002611875 1
                    "AT333" 1992 "A0" "AT"                   0 6.836905          0 1
                    "AT121" 1992 "A0" "AT" .040816329419612885 6.836905 .005970001 1
                    "AT124" 1992 "A0" "AT"                   0 6.836905          0 1
                    "AT211" 1992 "A0" "AT"                   0 6.836905          0 1
                    "AT226" 1992 "A0" "AT"                   0 6.836905          0 1
                    "AT122" 1992 "A0" "AT"                   0 6.836905          0 1
                    "AT225" 1992 "A0" "AT"                   0 6.836905          0 1
                    "AT224" 1992 "A0" "AT"                   0 6.836905          0 1
                    "AT127" 1992 "A0" "AT"                   0 6.836905          0 1
                    "AT212" 1992 "A0" "AT"                   0 6.836905          0 1
                    "AT314" 1992 "A0" "AT"                   1 6.836905  .14626502 1
                    end

                    Comment


                    • #11
                      Again, your data extract works just fine. I am currently using your code in #1, as modified by me in #8 (so, avoiding all the preserve and restore stuff).

                      Here are the contents of the resulting file:
                      Code:
                      . list, noobs
                      
                        +----------------------------------------+
                        | cod_tech   year       theil       gini |
                        |----------------------------------------|
                        |        1   1990   .09034291   .2329588 |
                        |        1   1991   .36144576    .443865 |
                        |        1   1992   .36755615   .4165848 |
                        +----------------------------------------+

                      Comment


                      • #12
                        Unfortunately, our results do differ - assuming it's not my computer one would imagine there has been a miscommunication somewhere - to confirm the do file you are using is the following


                        * Generate helper variables
                        gen ipc3 = substr(ipc4, 1, 3)
                        gen ipc2 = substr(ipc4, 1, 2)
                        gen country = substr(nuts3, 1, 2)

                        * Collapse to regional totals
                        collapse (sum) sh_pat, by(country nuts3 ipc2 year)
                        bysort country ipc2 year: egen tot_pat_cpt = total(sh_pat)
                        gen share_region = sh_pat / tot_pat_cpt
                        egen cod_tech = group(country ipc2)

                        * Set trace on for debugging
                        set trace on

                        * Step 2: Theil and Gini Indices
                        tempfile tgresults
                        tempname tgpost
                        postfile `tgpost' double cod_tech int year double theil gini using `tgresults', replace

                        levelsof cod_tech, local(countries)
                        levelsof year, local(years)

                        foreach c of local countries {
                        foreach y of local years {
                        local if_cond cod_tech == `c' & year == `y'
                        quietly count if `if_cond' & share_region > 0
                        if r(N) >= 2 {
                        quietly ineqdeco share_region if `if_cond'
                        local gini = r(gini)
                        local theil = r(ge1)
                        }
                        else {
                        local gini = .
                        local theil = .
                        }
                        post `tgpost' (`c') (`y') (`theil') (`gini')
                        }
                        }

                        postclose `tgpost'
                        use `tgresults', clear
                        save theil_gini_cod_tech.dta, replace



                        Last edited by Adam Rennett; 24 Jul 2025, 08:25.

                        Comment


                        • #13
                          Again, the code in #12, along with your data extract in #10, produces the same output file I listed in #11. I'm not sure why it doesn't work on your system. It would be helpful to show us the output of the trace from the Results window. Before you do that, just to ensure that the output isn't unmanageably large, also add this line just before set trace on:
                          Code:
                          set tracedepth 1

                          Comment


                          • #14
                            I don't think that line of code has done much to shorten my ouptut - which, unfortunately, remains unmanageable - I have attached the final few chunks of output but as i say the line still returns no observations -------------------------------------------------------------------------------------------------------------------------------------------------------- end ineqdeco ---
                            - local gini = r(gini)
                            - local theil = r(ge1)
                            - }
                            - else {
                            local gini = .
                            local theil = .
                            }
                            - post `tgpost' (`c') (`y') (`theil') (`gini')
                            = post __000000 (9) (2019) (.5036547934100786) (.5389381397541977)
                            - }
                            - }
                            - foreach y of local years {
                            - local if_cond cod_tech == `c' & year == `y'
                            = local if_cond cod_tech == 10 & year == 1990
                            - quietly count if `if_cond' & share_region > 0
                            = quietly count if cod_tech == 10 & year == 1990 & share_region > 0
                            - if r(N) >= 2 {
                            - quietly ineqdeco share_region if `if_cond'
                            = quietly ineqdeco share_region if cod_tech == 10 & year == 1990
                            ------------------------------------------------------------------------------------------------------------------------------------------------------ begin ineqdeco ---
                            - version 8.2
                            - syntax varname(numeric) [aweight fweight pweight iweight] [if] [in] [, BYgroup(varname numeric) Welfare Summarize ]
                            - if "`summarize'" != "" local summ "summ"
                            = if "" != "" local summ "summ"
                            - if "`welfare'" != "" local w "w"
                            = if "" != "" local w "w"
                            - local inc "`varlist'"
                            = local inc "share_region"
                            - tempvar fi totaly py gini wgini im1 i0 i1 i2 nk vk fik meanyk varyk lambdak loglamk lgmeank thetak im1k i0k i1k i2k ginik pyk im1b i0b i1b i2b wginik ahalf a1 a2 ahalf
                            > k a1k a2k whalf w1 w2 whalfk w1k w2k ahalfb a1b a2b edehalfk ede1k ede2k edehalf ede1 ede2 withm1 with0 withh with1 with2 awithh awith1 awith2 wi first
                            - if "`weight'" == "" gen byte `wi' = 1
                            = if "" == "" gen byte __00001O = 1
                            - else gen `wi' `exp'
                            = else gen __00001O
                            - marksample touse
                            - if "`bygroup'" != "" markout `touse' `bygroup'
                            = if "" != "" markout __00001Q
                            - qui count if `touse'
                            = qui count if __00001Q
                            - if r(N) == 0 error 2000
                            no observations
                            -------------------------------------------------------------------------------------------------------------------------------------------------------- end ineqdeco ---
                            local gini = r(gini)
                            local theil = r(ge1)
                            }
                            else {
                            local gini = .
                            local theil = .
                            }
                            post `tgpost' (`c') (`y') (`theil') (`gini')
                            }
                            }
                            r(2000);

                            end of do-file



                            I will converse with my supervisor and see if a more professional pc will help this run than my laptop if that is the last hope - I really do appreciate your perseverence today

                            Comment


                            • #15
                              Are you running this on the data extract you provided, or something else?

                              Also, I seriously doubt this has anything to do with the power of your PC. Changing the computer will almost certainly not fix the issue.
                              Last edited by Hemanshu Kumar; 24 Jul 2025, 10:15.

                              Comment

                              Working...
                              X