Statalist


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

Re: st: AW: Trouble with quotes in defining macro


From   Miranda Kim <mk@mrc.soton.ac.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: AW: Trouble with quotes in defining macro
Date   Wed, 11 Nov 2009 16:56:36 +0000

I am running a series of cox regressions using stcox, and displaying the results in a table using esttab.
I wanted to use the labels of certain variables as the column headers.
The option in esttab would be to have mtitle("Model 1" "Model 2" "Model 3")
so I was trying to create a local containing the string ""lab1" "lab2" "lab3"" to put in this option. I have tried using compound quotes but have no experience of using these and cannot get a code that works.
BW
Miranda

I want to put variable labels as the column

Martin Weiss wrote:
<>

My advice would be for you to provide the entire context of your problem.
There are solutions to the specific question you are asking, but I am quite
sure there is a way to avoid these awkward quotes...



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Miranda Kim
Gesendet: Mittwoch, 11. November 2009 17:37
An: statalist@hsphsun2.harvard.edu
Betreff: st: Trouble with quotes in defining macro

I have the following problem:

Within a loop I want to define a macro as follows:

Foreach var of varlist var1 var2 var3 {
local varlabs `varlabs' "`:var l `var''"
}

I want the macro varlabs to contain the following string ““lab1” “lab2” “lab3””, where lab1 is the label for var1 etc.
But I’m having problems with the quotes.
I then want to use this local as an argument in another command and that is why I wish it in this format with quotes around each label.
I am using stata 10.
Many thanks for your help.


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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