Announcement

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

  • Number of firms by different countries

    Hi STATA experts,

    I am try to generate a descriptive statistics table that showing the number of firms within each country (having 711 companies in 12 countries), but each time i try to do this it shows me the number of observations by country rather than the number of firms by country
    Code:
    . tabstat A , by ( C ) stat(n mean    median    max    min)    format
    
    Summary for variables: A
    by categories of: C 
    
    C          N      mean    p50        max    min
                    
    1       1744  230.1703    191        698    1
    2        606 229.61221    218        667    2
    3        282 178.53901    135        659    5
    4       1086 416.03039    445        714    10
    5        982 295.39817    258        700    11
    6        759 293.15283    272        702    12
    7       2303 418.98567    413        716    23
    8       1557  503.2569    530        715    25
    9        254 349.71654    392        636    27
    10        682 414.10704    441        649    69
    11         45 313.66667    225        540    176
    12         45 380.33333    376        459    306
                    
    Total      10345 358.26747    358        716    1
                    
    
    .
    Would appreciate your help !

  • #2
    Without any explanation of your data, much less an example to work with, it is difficult to say where your problem might be. This topic appears to be a continuation of

    https://www.statalist.org/forums/for...atistics-table

    and would more appropriately have been added to that topic.

    The notes in the table you are trying to match from the earlier topic suggests you have panel data with observations of firms over a number of fiscal years.

    In that case, you need to prevent the same company/country combination from being counted more than one time. I'm guessing A is your company code and C is your country code. Then
    Code:
    egen tocount = tag(C A)
    will create an indicator that is 1 for just one occurrence of each company/country combination.

    At this point
    Code:
    tab country if tocount==1
    will give you a count of companies by country.

    I don't at all see the point of the mean, p50, max, and min of the company codes within each country. And in the table on the earlier topic I don't understand or see the point of what they show beyond the count of firms.

    Comment


    • #3
      Thanks for your reply William,
      Yes, its continuation of the previous post. Check the below images for the data.
      I have already specified a number for each firm (variable A), and a number for each country (variable C).



      I tried the code you provide earlier, but get the below results
      Code:
      . egen tocount = tag(C A)
      unknown egen function tag()
      r(133);
      Presenting the mean of the company codes within each country may provide a weight indication for each country from the overall sample, am i right? but i am not sure about the rest !

      Thank you very much
      Attached Files
      Last edited by Hamza Almustafa; 20 Oct 2019, 23:43.

      Comment


      • #4
        If tag() is declared unknown then the issue may be that you inadvertently introduced a non-printable character in your statement. Check to see what egen knows by
        Code:
        help egen
        Otherwise the bad news is that your Stata installation appears to be corrupt or incomplete in some way.
        tag() has been official since Stata 7.

        Focusing on your question: I think you have here a very common question, as in this variant from 15 October:


        https://www.statalist.org/forums/for...noring-missing

        Comment


        • #5
          Thanks Nick for your comments. I cant find any issue with the data, but seems the Stata version issue!

          Comment


          • #6
            Please show us the result of


            Code:
            which _gtag 
            If your version is not Stata 16 you should be telling us the result of

            Code:
            version
            See https://www.statalist.org/forums/help#version (and while you're visiting drop in at https://www.statalist.org/forums/help#spelling ).

            Comment


            • #7
              Code:
              . which _gtag
              C:\Users\PC\AppData\Local\Temp\Rar$EXa0.217\StataCorp Stata 14.2 (Revision 30 Jan, 2018)\ado\base\_\_gtag.ado
              *! version 7.0.1  01oct2004

              Comment


              • #8
                You answered one question directly and one question by accident, so a 50% mark might seem harsh.

                But: good news. There is code for tag() on your system.


                Your Stata is 14.2 so the advice in the FAQ Advice flagged earlier still holds:

                11. What should I say about the version of Stata I use?

                The current version of Stata is 16. Please specify if you are using an earlier version; otherwise, the answer to your question may refer to commands or features unavailable to you. Moreover, as bug fixes and new features are issued frequently by StataCorp, make sure that you update your Stata before posting a query, as your problem may already have been solved.
                However, in this case I doubt that there is a problem. My guess remains my first guess. I can see no reason why


                Code:
                 
                 egen tocount = tag(C A)
                should fail, but type it directly, Don't copy and paste from a browser, as I think that was inadvertently the problem.

                Comment


                • #9
                  I typed it directly, but it failed again!

                  Tried to update the version also, but seems it corrupted!


                  Thanks for your usual support Nick

                  Comment


                  • #10
                    14.2 might well be up-to-date. I can't add further guesses.

                    Comment


                    • #11
                      Thanks a lot Nick

                      Comment


                      • #12
                        Is there any way to upload my data file here so someone can check this for me?

                        Comment


                        • #13
                          The FAQ Advice gives explicit and specific advice on giving data examples. If you're suspicious that your Stata is corrupted, I don't see that we shouldn't be wary of anything else it might produce.

                          Looking again at #7 I see

                          C:\Users\PC\AppData\Local\Temp\Rar$EXa0.217\StataC orp Stata 14.2 (Revision 30 Jan, 2018)\ado\base\_\_gtag.ado

                          and (let me put this candidly) that looks like a pirated Stata to me. Put it this way: Stata installation software doesn't suggest such a place for installation and I find it hard to guess that you chose such a place yourself. Someone sold or gave you an unauthorised version. If I am wrong, then sorry, but what's the different story?
                          Last edited by Nick Cox; 21 Oct 2019, 07:56.

                          Comment


                          • #14
                            I agree with Nick's assertion about the installation location. I think it possible you will find that your problems are not limited to egen's tag() function - other egen functions may also fail to be found. I will add that your data is not the source of your problem: Stata's egen command is failing to find the ado file that Stata's which command had found. To prove the data is not the problem, try the following.
                            Code:
                            . clear
                            
                            . set obs 10
                            number of observations (_N) was 0, now 10
                            
                            . set seed 42
                            
                            . generate x = runiformint(1,3)
                            
                            . egen y = tag(x)
                            
                            . tab x y
                            
                                       |        tag(x)
                                     x |         0          1 |     Total
                            -----------+----------------------+----------
                                     1 |         2          1 |         3 
                                     2 |         2          1 |         3 
                                     3 |         3          1 |         4 
                            -----------+----------------------+----------
                                 Total |         7          3 |        10 
                            
                            .
                            An alternative story of the inappropriate installation is that you are running Stata on an institutional Windows system on which Stata was installed by an IT specialist not knowledgeable in Stata, whose software distribution procedures involve cloning an initial installation onto the target systems using RAR to create a clone, rather than running the Stata installer on each target system. If that, or something like it, is the case, you should seek help from the institutional group responsible for installing Stata on the system you are using. If not, you could contact Stata Technical Services at https://www.stata.com/support/tech-support/ for their assistance in correcting your installation. Be sure to have your license information at hand.

                            Code:
                            . about
                            
                            Stata/SE 16.0 for Mac (64-bit Intel)
                            Revision 16 Oct 2019
                            Copyright 1985-2019 StataCorp LLC
                            
                            Total physical memory:    8.01 GB
                            
                            Single-user Stata perpetual license:
                                   Serial number:  42
                                     Licensed to:  Ford Prefect
                            Last edited by William Lisowski; 21 Oct 2019, 09:57.

                            Comment


                            • #15
                              Dear Nick and William,

                              Thanks a lot for your guidance and explanations.


                              William, you're right,
                              Stata was installed by an IT specialist not knowledgeable in Stata, whose software distribution procedures involve cloning an initial installation onto the target systems using RAR to create a clone, rather than running the Stata installer on each target system
                              I will contact my employer's IT department tomorrow to discuss this issue.


                              Thank you once again for this, appreciated


                              Hamza

                              Comment

                              Working...
                              X