Announcement

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

  • How to Save a File After a String Value

    Hello. This should be rather easy for folks here, but I am stymied.

    I have a rather simple dataset; 4 columns, 1 row:

    county state fips year
    1 Alachua_County FL 12001 2015

    I am wanting to save this file using the contents within county[1], i.e., "Alachua_County." I am using the following commands:

    local county "county[1]"
    di `county'
    save "C:/.../`county'.dta", replace

    However, this does not work. What I get is a file saved as county[1].dta. What I am wanting is a file saved as Alachua_County.dta.

    Thanks in advance for your assistance.





  • #2
    Code:
    local county = county[1]
    save "C:/.../`county'.dta", replace
    Your original command, -local county "county[1]" just sets the value of county to the string "county[1]", not to "Alachua_County". So, the subsequent -save- command created a file called county[1].dta. To get the value of county[1] stored in local macro county, not the string "county[1]", you need that equals sign in the command.

    Comment


    • #3
      Thank you, Clyde. With great appreciation.

      Comment

      Working...
      X