Announcement

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

  • Collapse problems with STATA 17

    Hi,
    I am not sure if it is a matter of discussion in the forum, but here it goes. I upgraded this week to the STATA 17, and with the STATA 16, all my do-files commands were working perfectly fine.
    But now, when it reaches the part to collapse my variables. The STATA closes all the windows and stops working. And I have to initiate the program all over again.

    Bellow is my collapse command. I am collapsing the information by household yearly.

    collapse (firstnm)village (firstnm)district (firstnm)state (firstnm)religion (max)h_size (sum)prime_age_male (sum)prime_age_fem (sum)elderly_male (sum)elderly_fem (sum)boy (sum)girl (firstnm)h_gender (max)h_male (max)h_age (max)h_yrs_edu (max)h_notworking (max)h_farmwork (max)h_salaried_work (max)h_other_work (sum)nw (sum)fw (sum)sl (sum)ot, by (sur_yr vdsid)

    Does anyone have some advice?

    Thank you!

  • #2
    Since Stata quit with no warning, this seems likely to be a bug in Stata, or a problem with your installation, since Stata is usually good about giving error messages when something is wrong.

    To see if your copy of Stata 17 is installed correctly, follow the link to the Stata Installation Qualification Tool found on https://www.stata.com/install-guide/

    Follow the instructions to download and run this tool to check the integrity and completeness of your Stata installation.

    If no problems are reported, you should contact Stata Technical Services. For instructions, click on the "Technical support" link at the bottom of the page displayed by the URL above, or almost any other page at stata.com.

    Comment


    • #3
      Ingrid Leiria . There is a bug in Stata17 collapse, with firstnm and lastnm, applied to string variables where all observations in a -by- group has are empty strings, it will crash Stata. We are in the process of fixing the bug and will release an update as soon as possible.

      If you would like to test the fixed executable before it's available, please contact tech support at [email protected].

      Thanks.

      Comment


      • #4
        This is to report another bug in collapse in Stata 17. I am posting it here because it fits with the subject, though it is a different problem from the one identified by the original poster.

        Here's a trivial MWE:

        Code:
        sysuse auto
        collapse price if make == "any thing"
        This yields the error

        Code:
        type mismatch
        r(109);
        I traced the problem. It is an issue in collapse_17.ado, specifically in line 124, where we need compound quotes and not simply double quotes. The current line reads

        Code:
        if "`if'`in'`wgt'" != "" {
        whereas it should be

        Code:
        if `"`if'`in'`wgt'"' != "" {

        Comment


        • #5
          Thanks for detailed report and fix of the bug. It will be fixed in a future Stata 17 update.

          Comment


          • #6
            I'm experiencing the same problem described by Ingrid using STATA 17. I just wanted to know if an update with a fix to the bug has already been released?

            Comment


            • #7
              The problem described in post #1 was fixed in the 05may2021 Stata 17 update, and the problem described in post #4 was fixed in the 19oct2021 update, according to the output of
              Code:
              help whatsnew
              which tells us
              Code:
              Title
              
                  Additions to Stata since release 17.0
              
              ...
              ------- update 05may2021 ---------------------------------------------------------------------------
              ...
                   9. collapse, when stat firstnm or lastnm applied to string variables where all observations
                      were empty strings or when a group defined by by(varlist) had empty strings, crashed Stata.
                      This has been fixed.
              ...
              ------- update 05oct2021 ---------------------------------------------------------------------------
              ...
                   7. collapse with condition if having a string containing a space produced an uninformative
                      error message.  This has been fixed.
              Last edited by William Lisowski; 04 Jan 2022, 16:27.

              Comment


              • #8
                It was fixed in the 5 May 2021 update. Run -update query- to see if your version is older than that, if you are not sure.

                Added: Crossed with #7. Hmm, this may be the first time I provide the same response as William Lisowski but with fewer words.

                Comment


                • #9
                  Hi all,

                  I seem to be facing another bug with the collapse command on Stata 17.

                  I am collapsing a binary variable by group and year.

                  Code:
                  collapse (mean) voted, by(group year)
                  There are around 300 observations per group-year cluster. The issue is that the collapse gives me back a binary variable again, with just 1s and 0s as the original variable, while it should be giving me back a float, with all values being between 0 and 1.
                  Indeed, if I run "sum" on the collapsed variable I get:


                  . sum voted

                  Variable | Obs Mean Std. dev. Min Max
                  -------------+---------------------------------------------------------
                  voted | 360 .1917622 .2175112 0 .6766169


                  The Max is showing something coherent with what it should be, but checking with "tab" I only get 1s and 0s.

                  Is there a simple explanation for this which I'm not seeing? or is it a bug? Forgive me if this is trivial, I usually manipulate data on R.

                  Thanks!


                  Comment


                  • #10
                    EDIT: I solved the issue but I can't delete the comment.
                    The issue was with the data format being an integer. After changing the format to a float, the collapse works.

                    Comment


                    • #11
                      The problem is that your voted variable has a format like %9.0f in your original dataset, which is carried across to your collapsed dataset, which then displays the fractional value with no decimal places.
                      Code:
                      . sysuse auto, clear
                      (1978 automobile data)
                      
                      . format rep78 %9.0f
                      
                      . collapse (mean) rep78, by(foreign)
                      
                      . list
                      
                           +------------------+
                           |  foreign   rep78 |
                           |------------------|
                        1. | Domestic       3 |
                        2. |  Foreign       4 |
                           +------------------+
                      
                      . format %9.4f rep78
                      
                      . list
                      
                           +-------------------+
                           |  foreign    rep78 |
                           |-------------------|
                        1. | Domestic   3.0208 |
                        2. |  Foreign   4.2857 |
                           +-------------------+
                      
                      .
                      Added in edit: You cannot delete your post, nor should you edit it into oblivion when that is possible within an hour of its original posting. You asked a question and then you found the answer, and this exchange amongst yourself could be useful to others with similar problems, or serve as an instructive piece of information to those reading it now. Statalist is not a help line, it is a discussion forum among users of Stata. Posting your answer is appreciated.
                      Last edited by William Lisowski; 04 Feb 2022, 08:09.

                      Comment


                      • #12
                        On deleting comments. This is explained in the FAQ:

                        You cannot delete a post, but the forum allows for a one hour edit window. This allows fixes of many kinds, such as typo corrections, extra detail, or improved wording. Please don't mangle your own posts, even if you solved your problem yourself or realised that the question was silly. Explain the solution, even if it was trivial. Often someone else will have the same problem.
                        Edit: crossed with #11
                        Last edited by Leonardo Guizzetti; 04 Feb 2022, 08:13.

                        Comment


                        • #13
                          I am using a Windows 11 operating system and I regularly experience crashes after updating to STATA 17. Usually, it happens when I try to plot a graph, such as a box plot or a histogram. The interesting thing is that it is not consistent. After the crash, I rerun the command, and this time it works. It is frustrating. Do you think I should uninstall and reinstall?

                          Comment


                          • #14
                            Well, before you uninstall and reinstall Stata, first check if you have the latest updates. So run -update query-. If it says you are up to date and recommends you "do nothing," then uninstalling and reinstalling Stata, followed by -update all- once you have reinstalled, would be the most sensible thing. If -update query- recommends you install updates, then do that and see if that fixes the problem first.

                            Comment


                            • #15
                              Originally posted by Clyde Schechter View Post
                              Well, before you uninstall and reinstall Stata, first check if you have the latest updates. So run -update query-. If it says you are up to date and recommends you "do nothing," then uninstalling and reinstalling Stata, followed by -update all- once you have reinstalled, would be the most sensible thing. If -update query- recommends you install updates, then do that and see if that fixes the problem first.
                              Thanks for the suggestions!

                              Comment

                              Working...
                              X