Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: Triming labels.


From   adiallo5@worldbank.org
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: Triming labels.
Date   Fri, 12 Nov 2004 12:22:47 -0500

I mean:

              mat M= M \r(Stat`j')




                                                                                                                                           
                      adiallo5@worldbank.org                                                                                               
                      Sent by:                         To:       statalist@hsphsun2.harvard.edu                                            
                      owner-statalist@hsphsun2.        cc:                                                                                 
                      harvard.edu                      Subject:  Re: st: RE: Triming labels.                                               
                                                                                                                                           
                                                                                                                                           
                      11/12/2004 12:18 PM                                                                                                  
                      Please respond to                                                                                                    
                      statalist                                                                                                            
                                                                                                                                           
                                                                                                                                           
                                                                                                                                           
                                                                                                                                           




Thanks David.

This solution is to label a variable. What if you want to save as a macro?
I try your suggestion but it returns missing.

In fact, I want to put the label in a local macro. I am doing something like
this:


prog mytab

...

qui tabstat `varlist' [`weight' `exp'], stats(mean) long save
mat M=r(StatTot)
local matvar "National"

foreach i in urban region sex marstat {
       cap confirm numeric `i'
       qui {
               lab li `i'
               local min = r(min)   /*To get the minimum value*/
               local max=r(max) /*To get the maximum value*/
        }

qui tabstat `varlist' [`weight' `exp'], stats(mean) by(`i') long save
      forval j=`min'/`max' {
               local lab`j': label `i' `j'
               local matvar "`matvar' `lab`j''"
              mat M= M \r(Stat`i')
        }
    }
}
mat M = M'
local matvar: list uniq matvar
mat colnames M = `matvar'
mat li M, f(%4.3f)
end

I am getting conformability error because the labels have blanks.

Best regards.








                      "David Harrison"

                      <David@icnarc.org>               To:
<statalist@hsphsun2.harvard.edu>
                      Sent by:                         cc:

                      owner-statalist@hsphsun2.        Subject:  st: RE: Triming
labels.
                      harvard.edu



                      11/12/2004 11:20 AM

                      Please respond to

                      statalist









-trim()- only removes leading and trailing blanks. To remove embedded blanks you
will need to use something like -subinstr()-.

Are you talking about variable labels or value labels? If variable labels, then
something along the lines of

foreach v of varlist _all {
             label var `v' "`=subinstr("`: var lab `v''"," ","",.)'"
}

should remove all embedded blanks from all variable labels (which may be a
little overkill!) - to limit to certain variables change the -_all- to the
varlist you want changed.

Something along similar lines ought to work for value labels.

David
david@icnarc.org

-----Original Message-----
From: adiallo5@worldbank.org [mailto:adiallo5@worldbank.org]
Sent: 12 November 2004 16:10
To: statalist@hsphsun2.harvard.edu
Subject: st: Triming labels.


Hi,

How to remove blanks in labels (for example : "Region\ South" to
"Region\South")?
I am trying trim but it is not working.
Best regards.
Amadou.

*
*   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/



*
*   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/




*
*   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/




*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index