Search code examples
statastata-macros

File paths and local macros


Suppose that I am in a folder ~/top. There is a file path like this: ~/top/middle/bottom folder.

I want to define a local macro and then use it in the file path.

What I have done is the following:

local target ""bottom folder""
cd "middle"
cd `target'

This works fine but I can't figure out how to combine lines two and three into a single line.

I have tried cd "middle/`target'" andcd ""middle/"+`target'" but these are wrong.


Solution

  • Assuming you are already in the directory top, the following should work:

    local target bottom folder
    cd "middle/`target'"