Announcement

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

  • Display frame name

    How can I display / print the name of the frame that I am in:
    Code:
    sysuse auto
    frame put foreign if foreign == 1,into (one)
    frame put foreign if foreign == 2,into (two)
    frame dir
    frame change one
    I would like to display 'one'.

    Thank you,
    Eddy

  • #2
    At least in Stata 16, frame put do not allow you to specify varlist and if at the same time.
    Code:
    . frame put foreign if foreign == 1,into(one)
    if not allowed
    r(101);
    
    . 
    . frame put foreign if foreign == 2,into(two)
    if not allowed
    r(101);

    Comment


    • #3
      Code:
      display c(frame)
      I have to wonder: Why would you want to display the frame name? The only situation in which I see how that might be useful is in log-files.

      Comment


      • #4
        Just type frame

        Code:
        . frames reset
        
        . sysuse auto
        (1978 automobile data)
        
        . frame put foreign if foreign == 1,into (one)
        
        . frame put foreign if foreign == 2,into (two)
        
        . frame dir
          default  74 x 12; 1978 automobile data
        * one      22 x 1; 1978 automobile data
        * two      0 x 1; 1978 automobile data
        
        Note: Frames marked with * contain unsaved data.
        
        . frame change one
        
        . frame
          (current frame is one)
        ---------------------------------
        Maarten L. Buis
        University of Konstanz
        Department of history and sociology
        box 40
        78457 Konstanz
        Germany
        http://www.maartenbuis.nl
        ---------------------------------

        Comment


        • #5
          Thank you all.
          I was attemting to use frames in a rather long 'do' which was failing and I wanted to print the frame name to know which particular frame had caused the problem.
          With your help that is now resolved.
          Eddy

          Comment


          • #6
            I have to wonder: Why would you want to display the frame name?
            It's pretty useful. Sometimes, I wanna switch back to the original frame in scul, and that name may not always be default, so I store it in a macro as originalframe before I make the frames used in the analysis

            Comment


            • #7
              Originally posted by Jared Greathouse View Post
              It's pretty useful.
              I see that storing the name of the current and unknown frame name is useful. I still do not see how displaying, i.e., printing to the screen a known frame name is. If you have something like

              Code:
              frame change framename
              you know which frame you are changing to. Just follow that line with
              Code:
              display "framename"
              Am I missing something here?
              Last edited by daniel klein; 19 Jan 2023, 00:29.

              Comment


              • #8
                Oh yeah you're right. daniel klein storing it? Yep. Just printing it? No.

                Comment


                • #9
                  I’ve only found it helpful to use in interactive mode if I’m trying to do something quick as a one-off task and don’t really care about saving the workflow in a do file.

                  Comment


                  • #10
                    I use it for debuging: a big do-file throws an error, I quickly type frame to see which frame I am in. I could scroll up and see it in the code, but that is more work and it is easy to overlook while scrolling.
                    ---------------------------------
                    Maarten L. Buis
                    University of Konstanz
                    Department of history and sociology
                    box 40
                    78457 Konstanz
                    Germany
                    http://www.maartenbuis.nl
                    ---------------------------------

                    Comment

                    Working...
                    X