Announcement

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

  • Include -chartab- in Stata distribution.

    Comment


    • I know there's user written stuff for this, but one HUGE improvement would be to be able to directly write R code within Stata do files.

      Python integration has helped me beyond measure, and has allowed me to do things that i couldn't do before. So including R could would be a neat way to both learn R and not need to switch terminals if in case anyone needs to put their dataset into R and do some work

      Comment


      • I use -display- as a command line calculator a lot. What I find very annoying and inconvenient is that -display- does not store/return the result. (I read in the manual that -display- is an nclass command.)

        What I would like to be able to do is when I write

        Code:
        . display 2 + 3 + 4/2
        7
        after that to have the result (7 in this case) stored/returned somehow, say in r(result) or r(answer) or in n(result) or in n(answer), so that I am able to further use it. E.g., (imaginary code follows)

        Code:
        . display 2 + 3 + 4/2
        7
        
        . display r(answer)*33



        Comment


        • Originally posted by Joro Kolev View Post
          I use -display- as a command line calculator a lot. [...] What I would like to be able to do is when I write

          Code:
          . display 2 + 3 + 4/2
          7
          after that to have the result (7 in this case) stored/returned somehow, say in r(result) or r(answer) or in n(result) or in n(answer), so that I am able to further use it. E.g., (imaginary code follows)

          Code:
          . display 2 + 3 + 4/2
          7
          
          . display r(answer)*33
          How about

          Code:
          . local answer : display 2 + 3 + 4/2
          
          . display `answer'*33
          231

          By the way, I find Mata useful for that, too

          Code:
          . mata
          ------------------------------------------------- mata (type end to exit) ---------------------------------------------------------------------------------------------------------------------------
          : answer = 2 + 3 + 4/2
          
          : answer*33
            231
          
          : end
          -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
          Last edited by daniel klein; 28 Aug 2022, 06:03.

          Comment


          • This of course works, Daniel. I end up doing something similar, except that for some reason I seem to prefer to work with scalars, so I assign these quantities to scalars. I actually know the reason, I dislike typing ` and 's.

            Still this is awkward and unneeded. When using -display- I see the result but the result is not saved for further manipulations. When I use scalars or locals, the result is saved but I do not see it. And with locals I have the added pleasure that to see it I have to type lots of ` and 's.

            I think we need a new rule: Every command in Stata has to show the result for visual inspection, and also save the result for further manipulation somewhere.

            Originally posted by daniel klein View Post

            How about

            Code:
            . local answer : display 2 + 3 + 4/2
            
            . display `answer'*33
            231

            By the way, I find Mata useful for that, too

            Code:
            . mata
            ------------------------------------------------- mata (type end to exit) ---------------------------------------------------------------------------------------------------------------------------
            : answer = 2 + 3 + 4/2
            
            : answer*33
            231
            
            : end
            -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

            Comment


            • Originally posted by Joro Kolev View Post
              I think we need a new rule: Every command in Stata has to show the result for visual inspection, and also save the result for further manipulation somewhere.
              I am not sure I like to have my programs return error messages in r() and wipe previous r() results when they fail or every time I display something. I also see little benefit in, say, save returning the string "file filename.dta saved" in r().
              Last edited by daniel klein; 28 Aug 2022, 09:34.

              Comment


              • #456 reminds me of a wish of my own:

                Make nclass more than a comment. If a program is declared nclass, then e(), r(), and s() should not have changed their contents when that program concludes.
                Last edited by daniel klein; 28 Aug 2022, 09:47.

                Comment


                • I am pretty sure that you as a programmer should save whatever you need in r() for further use, and not hope for the whole software to adjust around you, because you have a programming style that lets r() results hanging out there for later use.

                  Apart from that, you are raising valid points of whether -display- should be classified as an n-class command. And that some commands return inane results in r(). And that you have different uses of -display-. Who knows, maybe there should be a separate command -calculate- which does what I want, and a separate command -display- which you can use in your programmes without overwriting previous results returned.

                  I am pretty sure thought that what -display- and -matlist- do currently (not leave anything behind in r() or anywhere else) is dysfunctional for my purposes. And this needs to be fixed because on my list of dysfunctionality this rates about the same level as -regress- showing you the regression estimates, but not making them available for later use in any way.

                  Originally posted by daniel klein View Post

                  I am not sure I like to have my programs return error messages in r() and wipe previous r() results when they fail or every time I display something. I also see little benefit in, say, save returning the string "file filename.dta saved" in r().

                  Comment


                  • If something like this is actually needed, why not make your own program that does exactly that:
                    Code:
                    *Stores display on r(return)
                     program rdisplay, rclass
                        display `0'
                        local ret:display `0'
                        return scalar return = `ret'
                    end
                    *stores it on scalar with the name you choose
                     program sdisplay,  
                        gettoken scn 0:0
                        display `0'
                        local ret:display `0'
                        scalar `scn'= `ret'
                    end
                    These are very basic, but one could adjust them to cover more cases.
                    F

                    Comment


                    • This isn't a part of the code but a thought on policies. I am moving to emeriti status and so my university will no longer pay for Stata. With the end of perpetual licenses I will have to pay out of pocket for Stata in about two years. So after 30 years of using and teaching Stata almost exclusively I will reluctantly switch to R as I plan to continue doing research. I'm wondering if Stata could have a pricing policy of the sort used by many scientific societies--with a special rate for retirees.

                      Comment


                      • I would like to see a Statacorp -using- option for -describe- that obviated the need for -descsave- and that doesn't have to read the entire dataset to get the list of variables and types. The processing time should be short and proportional to the number of variables, not the number of observations. The -using- option of -descsave- is great, but loading a large dataset can be time consuming, and shouldn't be necessary just to get the variable names and types. For example:

                        Code:
                         set obs 1
                        gen x=1
                        save stuff1,replace
                        descsave using stuff1,saving(stuff2,replace) fast
                        clear
                        set obs 100000000
                        gen x=1
                        save stuff3,replace
                        descsave using stuff3,saving(stuff4,replace) fast
                        The first -descsave- is .01 seconds, the 2nd is 3.3 seconds on a machine here. I have files here that take hours for a -descsave- .

                        Comment


                        • Originally posted by [email protected] View Post
                          I would like to see a Statacorp -using- option for -describe- that obviated the need for -descsave- and that doesn't have to read the entire dataset to get the list of variables and types. The processing time should be short and proportional to the number of variables, not the number of observations. The -using- option of -descsave- is great, but loading a large dataset can be time consuming, and shouldn't be necessary just to get the variable names and types. For example:

                          Code:
                           set obs 1
                          gen x=1
                          save stuff1,replace
                          descsave using stuff1,saving(stuff2,replace) fast
                          clear
                          set obs 100000000
                          gen x=1
                          save stuff3,replace
                          descsave using stuff3,saving(stuff4,replace) fast
                          The first -descsave- is .01 seconds, the 2nd is 3.3 seconds on a machine here. I have files here that take hours for a -descsave- .

                          The request regarding describe using is noted. In the meantime, if you look at line 184 of descsave.ado, you will see part of the line reads use if 0. While that is a good thing in that descsave doesn't use up memory by loading the entire dataset, it still requires Stata look at every observation of the dataset being loaded, as the if condition has to be re-evaluated for each observation. If you change the code to use in 1, then descsave should become nearly instantaneous for you.

                          I'm tagging Roger Newson as this is his command, so he may want to take a look to see if my suggested modification has any unintended consequences.

                          Comment


                          • That does help a lot! I don't notice anything missing from the result, but I am not using all the other options.

                            Thanks.

                            Comment


                            • Originally posted by Tom Dietz View Post
                              This isn't a part of the code but a thought on policies. I am moving to emeriti status and so my university will no longer pay for Stata. With the end of perpetual licenses I will have to pay out of pocket for Stata in about two years. So after 30 years of using and teaching Stata almost exclusively I will reluctantly switch to R as I plan to continue doing research. I'm wondering if Stata could have a pricing policy of the sort used by many scientific societies--with a special rate for retirees.
                              Tom (or anyone else), I do not recall hearing/reading that perpetual licenses would no longer be available. Where did you get that information? There is no mention of it in William Lisowski's post (#2) in this thread, for example. And I don't see anything suggesting abolition of perpetual licenses on this webpage. I certainly hope that perpetual licenses continue.

                              Thanks,
                              Bruce
                              --
                              Bruce Weaver
                              Email: [email protected]
                              Version: Stata/MP 18.5 (Windows)

                              Comment


                              • Tom Dietz I still renew my perpetual license via maintenance without issue. Perpetual licenses are still available as far as I’m aware.

                                Comment

                                Working...
                                X