Announcement

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

  • issues with global macro windows code on mac

    I am trying to use a Master do file that someone has sent me from their windows computer. I have a Mac and the project that was sent to me was based on a global macro, used to change to and from directories.

    Code:
    gl MP "/Users/Cassie/Desktop/data/Jared_Data"
    
        cd "$MP/Replication_Files/Management/Master"
    
    unable to change to /Users/Cassie/Desktop/data/Jared_Data/Replication_Files/Management/Ma
    > ster
    r(170);
    
    end of do-file
    The global MP is meant to be the master path for the project. To run the master management file, I have to change to the master management folder.

    I suspect that this is because there's a slight software difference between windows and Mac, any ideas what the problem might be?

  • #2
    Rather than the differences in the grammar of file references between Windows and Mac environments, the most likely explanation for this error message would be that you don't have a directory named "/Users/Cassie/Desktop/data/Jared_Data/Replication_Files/Management/Master"
    Have you checked that?

    If you don't have a directory by that name, you would need to make one, or to change the global to refer to some other existing directory you'd rather use.
    (And, by the way, another problem may occur if your colleague's code expects there to be some existing file(s) in that directory, but that's another matter.)

    Comment


    • #3
      So, does the folder /Users/Cassie/Desktop/data/Jared_Data/Replication_Files/Management/Master actually exist on your computer? Try accessing it from some other program. My guess is that it isn't there.

      This just a hunch, but since the code was developed in a Windows box and you are porting it to a Mac, one difference between them is that on the Mac, pathnames and filenames are case sensitive, whereas in Windows they are not. So I'm wondering if /data/ needs to be /Data/ on your machine, or some other such discrepancy.

      Added: Crossed with #2 who proposes a related, but different, issue.

      Comment


      • #4
        Originally posted by Mike Lacy View Post
        Rather than the differences in the grammar of file references between Windows and Mac environments, the most likely explanation for this error message would be that you don't have a directory named "/Users/Cassie/Desktop/data/Jared_Data/Replication_Files/Management/Master"
        Have you checked that?

        If you don't have a directory by that name, you would need to make one, or to change the global to refer to some other existing directory you'd rather use.
        (And, by the way, another problem may occur if your colleague's code expects there to be some existing file(s) in that directory, but that's another matter.)
        It already exists on my computer so I'm not sure why it's not finding it. Normally when I try and change directory I have no issue.

        Comment


        • #5
          Originally posted by Clyde Schechter View Post
          So, does the folder /Users/Cassie/Desktop/data/Jared_Data/Replication_Files/Management/Master actually exist on your computer? Try accessing it from some other program. My guess is that it isn't there.

          This just a hunch, but since the code was developed in a Windows box and you are porting it to a Mac, one difference between them is that on the Mac, pathnames and filenames are case sensitive, whereas in Windows they are not. So I'm wondering if /data/ needs to be /Data/ on your machine, or some other such discrepancy.

          Added: Crossed with #2 who proposes a related, but different, issue.
          As I was saying to Mike, it definitely does exist. I've also made sure that the code is case sensitive, so I'm not sure why it's not finding it. I wonder if I should just try it again with a new file and see if that works. I am also thinking that stata behaves differently on Macs than windows computers, for example,
          Code:
          gtools
          doesn't work for me. According to google, it bugs out on Macs.

          Comment


          • #6
            One potential issue is that the data could be in a zip file. Stata can't open (I don't think!!) files from within zip files. So if it's in some compressed format, I would extract these files to whatever directory you'd like to work from, and then proceed that way.

            Comment


            • #7
              As a Mac user, I have replicated this issue on my system - Stata 17 fully updated - and am totally at a loss for an explanation. Here is my test code, having first created the folder "gnxl" on my Desktop.
              Code:
              cls
              clear all
              cd /Users/lisowskiw
              cd /Users/lisowskiw/Desktop/gnxl
              cd /Users/lisowskiw
              global MP "/Users/lisowski/Desktop"
              cd "$MP/gnxl"
              cd /Users/lisowskiw
              local MP "/Users/lisowski/Desktop"
              cd "`MP'/gnxl"
              Here is the result of copying that code and pasting it, as a single block, into Stata's Command window.
              Code:
              . clear all
              
              . cd /Users/lisowskiw
              /Users/lisowskiw
              
              . cd /Users/lisowskiw/Desktop/gnxl
              /Users/lisowskiw/Desktop/gnxl
              
              . cd /Users/lisowskiw
              /Users/lisowskiw
              
              . global MP "/Users/lisowski/Desktop"
              
              . cd "$MP/gnxl"
              unable to change to /Users/lisowski/Desktop/gnxl
              r(170);
              
              . cd /Users/lisowskiw
              /Users/lisowskiw
              
              . local MP "/Users/lisowski/Desktop"
              
              . cd "`MP'/gnxl"
              unable to change to /Users/lisowski/Desktop/gnxl
              r(170);
              
              .
              I will continue to ponder this, but suggest that this question be addressed to Stata Technical Services at https://www.stata.com/support/tech-support/

              Comment


              • #8
                To my embarassment, I see the error in the code in post #7; when corrected I cannot reproduce the problem. In both the global and local commands I used "lisowski" where I should have used "lisowskiw".

                I suggest pasting the following commands into the Do-file Editor and running them:
                Code:
                cd "/Users"
                cd "/Users/Cassie"
                cd "/Users/Cassie/Desktop"
                cd "/Users/Cassie/Desktop/data"
                cd "/Users/Cassie/Desktop/data/Jared_Data"
                cd "/Users/Cassie/Desktop/data/Jared_Data/Replication_Files"
                cd "/Users/Cassie/Desktop/data/Jared_Data/Replication_Files/Management"
                cd "/Users/Cassie/Desktop/data/Jared_Data/Replication_Files/Management/Master"
                Let me add the following details of my macOS configuration, which I updated from macOS 12.1 yesterday, and my Stata version.
                Code:
                . shell system_profiler SPSoftwareDataType
                
                Software:
                
                    System Software Overview:
                
                      System Version: macOS 12.2 (21D49)
                      Kernel Version: Darwin 21.3.0
                      Boot Volume: Macintosh HD
                      Boot Mode: Normal
                      Computer Name: MacBook WL
                      User Name: William Lisowski (lisowskiw)
                      Secure Virtual Memory: Enabled
                      System Integrity Protection: Enabled
                      Time since boot: 4 minutes
                
                
                . about
                
                Stata/SE 17.0 for Mac (Intel 64-bit)
                Revision 17 Jan 2022
                Copyright 1985-2021 StataCorp LLC
                
                Total physical memory: 8.01 GB
                
                Stata license: Single-user  perpetual
                Serial number: [redacted]
                  Licensed to: William Lisowski
                              
                
                .
                Last edited by William Lisowski; 30 Jan 2022, 19:36.

                Comment

                Working...
                X