Statalist


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

st: List with strings containing spaces


From   "K Jensen" <[email protected]>
To   [email protected]
Subject   st: List with strings containing spaces
Date   Wed, 18 Jul 2007 14:07:01 +0100

Help! Yet again I am having problems with quotes. I am trying to
generate a list of strings, some of which contain spaces, in order to
provide more descriptive labels when I write the results of a
regression to a file.

For example:

sysuse cancer, clear
stset studytime, fail(died)
xi:stcox i.drug age
tempname B
matrix `B' = e(b)
tokenize "`: colfullnames `B''"
local pretty_names
forval j = 1/`= colsof(`B')' {
 if "``j''"=="_Idrug_2" {
   local pretty_names `pretty_names' DrugName2
 }
 else if "``j''"=="_Idrug_3" {
   local pretty_names `pretty_names' DrugName3
 }
 else if "``j''"=="age" {
   local pretty_names `pretty_names' Age(years)
 }
 else {
   local pretty_names `pretty_names' ``j''
 }
}

I would like the elements in the list pretty_names to actually be
"Drug name 2", "Drug name 3", "Age (years)".

Every attempt I make to create such a list (in practically every
combination of compound double and other quotes, tried out of despair)
results in either a syntax error or a list with too many elements,
where "Drug", "name", "2", etc are separate items.

Sorry to be so stupid,
Karin
*
*   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