[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: How to use the marco names?

From   Dan Blanchette <>
To   statalist <>
Subject   Re: st: How to use the marco names?
Date   Mon, 3 Aug 2009 10:21:59 -0400 (EDT)

The SSC command -fs-, returns the file names in the macro r(files) with double quotes around each filename.
So if you:

. fs *.csv
bs.csv     is.csv     price.csv  big.csv    share.csv  mag.csv    plu.csv

and use compound quotes around `r(files)':

. di `"`r(files)'"'
"bs.csvis.csv" "price.csv" "big.csv" "share.csv" "mag.csv" "plu.csv"

and use compound quotes again when setting the local macro hh:

. local hh `"`r(files)'"'

the double quotes around the filenames will be preserved.
The errors you experienced were due to the internal double quotes and
some of them being removed by Stata since you didn't use compound
double quotes.

The problem with:

. foreach i of local r(files) {

is that r(files) is not considered a local macro.

Hope this helps,

Dan Blanchette
Research Associate
Center for Entrepreneurship and Innovation
Duke University's Fuqua School of Business


© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index