Announcement

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

  • Creating a Log File in Current Directory

    Sorry this might seem to be a very elementary question, but how would I go about creating a log file in my current directory? (i.e. I would not need to provide an explicit path for it?)

  • #2
    You do this the same way you create any log file. Just specify a filename without a path.
    For example:

    log using "somelog"

    Comment


    • #3
      ^Whenever I'm using log using "varname" it says file Q:\STATA13.115\varname.smcl could not be opened. I don't run into this problem when I have an explicit path.

      Comment


      • #4
        You have to make sure your current directory is one to which you have write permission. When you say that you don't have this problem when you provide an explicit path do you mean that you don't have this problem when you provide Q:\STATA13.115\varname.smcl as the log file name? Or do you mean that if you provide a different path you are able to write the log?

        Comment


        • #5
          What I mean is that I don't have any problems when I explicitly create a path to the current directory. This leads me to believe that my problems are not with permissions, because provided I provide the explicit path to the current directory, I can create my log file there.

          Comment


          • #6
            I'm going to make a guess as to what Tom Wilson's difficulty is: he is opening Stata in the system directory where the Stata executable resides (which, if I am right, and based on his post, is Q:\STATA13.115), and he doesn't have privileges to write in that directory.

            Check what the current directory actually is with the command:

            pwd // IF YOU ARE RUNNING ON WINDOWS YOU CAN TYPE cd INSTEAD

            Any mention of a filename without an explicit path will be taken by Stata to mean a file in that directory. If that is a directory you don't have write privileges for, Stata will complain about that to you in the way you described.

            If you launched Stata by double-clicking on the program icon (or on a "shortcut" to it) Stata will open with the current working directory set to some system specific default value. It will generally not be the directory you have been working in up to that point on other things (nor will it remember the last directory you worked from in Stata) and is likely to be a directory that is "owned" by the system and for which you do not have write privileges.


            If I am right about that, you need to need to explicitly change the directory to the one you want Stata to be working in, by the command

            cd insert_name_of_desired_directory_here

            After that, plain old

            log using desired_log_name, replace // REPLACE OPTION ONLY NEEDED IF THAT FILE ALREADY EXISTS
            should work.

            A way to avoid this rigamarole is to launch Stata differently: double-click on a Stata .dta, .do, or .smcl file to launch it. Then Stata opens up with the working directory set to the directory where you did the double-click. From that point on all references to filenames are in that same directory unless you override that assumption by specifying an explicit pathname.

            Hope this helps.

            Comment

            Working...
            X