Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: manipulating macro from dir extended_fcn


From   n j cox <[email protected]>
To   [email protected]
Subject   st: manipulating macro from dir extended_fcn
Date   Tue, 18 Sep 2007 18:00:52 +0100

Never evaluate a macro when all you need
to do is copy it. I don't have access to
the manuals right now, but there is a big
chunk of [U] that makes this point.
Perhaps someone can fill in the section
number.

That is, whenever you go

global macname = <expression>

machinery of Stata springs into action that
(as a side-effect) may truncate the expression.
The = sign is an instruction to evaluate whatever
is to the right of it.

Treat the = sign here as dangerous.

global macname "<expression>"

is the way to go whenever you can.

Nick
[email protected]

Carlos Eduardo Hernandez Castillo

I am trying to manipulate the macro resulting from the dir extended_fcn.
However, it is truncated by Stata every time I try to change it. For
example:

. local archivos: dir "`dirdaneechareasmodificados'" files "*.dta"

. display `"`archivos'"'
"7areasa1991.dta" "7areasd2001.dta" "barranquilla.dta" "bogota.dta"
"bucaramanga.dta" "cali.dta" "manizales
>.dta" "medellin.dta" "nalech.dta" "nalenh.dta" "ocupados7areas_anual.dta"
>"ocupados7areas_trimestral.dta"
>  "ocupadosnacional_anual.dta" "ocupadosnacional_trimestral.dta"
>"ocupadosunificada_anual.dta" "pasto.dta"
>  "proporcionesnacional.dta" "temp.dta" "totalesbarranquilla.dta"
>"totalesbogota.dta" "totalesbucaramanga.
>dta" "totalescali.dta" "totalesmanizales.dta" "totalesmedellin.dta"
>"totalesnacional.dta" "totalespasto.d
>ta"

. global archivos=`"`archivos'"'

. display `"$archivos"'
"7areasa1991.dta" "7areasd2001.dta" "barranquilla.dta" "bogota.dta"
"bucaramanga.dta" "cali.dta" "manizales
>.dta" "medellin.dta" "nalech.dta" "nalenh.dta" "ocupados7areas_anual.dta"
>"ocupados7areas_trimestral.dta"
>  "ocupadosnacional_anual.dta" "oc

. local archivos=subinstr(`"`archivos'"',`"""',"",.)

. display `"`archivos'"'
7areasa1991.dta" "7areasd2001.dta" "barranquilla.dta" "bogota.dta"
"bucaramanga.dta" "cali.dta" "manizales.
>dta" "medellin.dta" "nalech.dta" "nalenh.dta" "ocupados7areas_anual.dta"
>"ocupados7areas_trimestral.dta" "ocupadosnacional_anual.dta" "oc

. local archivos=subinstr(`"`archivos'"',`"""',"",.)

. display `"`archivos'"'
7areasa1991.dta 7areasd2001.dta barranquilla.dta bogota.dta bucaramanga.dta
cali.dta manizales.dta medellin
>.dta nalech.dta nalenh.dta ocupados7areas_anual.dta
>ocupados7areas_trimestral.dta ocupadosnacional_anual.
>dta oc

I would appreciate any help from you regarding this issue. What can I do to
stop it from being truncated? I am using Stata 9.2. Thanks in advance for
your help.

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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