Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: RE: extract rownames corresponding to data as unique codes


From   Judy You <[email protected]>
To   [email protected]
Subject   Re: st: RE: extract rownames corresponding to data as unique codes
Date   Tue, 2 Aug 2011 10:42:49 +0930

Dear Nick,

i have tried your command, it gives me error message.

matrices:
                 r(se) :  1 x 95
                 r(ub) :  1 x 95
                 r(lb) :  1 x 95
                r(adj) :  1 x 95
              r(crude) :  1 x 95
               r(Nobs) :  1 x 95
number of observations will be reset to 95
Press any key to continue, or Break to abort
obs was 0, now 95
(95 missing values generated)
type mismatch
r(109);

end of do-file

r(109);

What i like to have SLAs (area codes) maintain the original source
(numeric format),eg., sla=201, 203 205 --- 4809, 5000 5050 etc..
instead of 1 to 95.

Cheers

Judy



2011/7/13 Judy You <[email protected]>
>
> Thanks Nick for your promptous response. SLA is an area code. Since i
> am away and have no stata program in my hand, i ccouldn't try to run
> it now, but i trust it will work fine.
>
> Cheers
>
> Judy
>
>
> 2011/7/11 Nick Cox <[email protected]>:
> > I don't know what SLAs are.
> >
> > In your case, the row names, originally column names, are apparently all numbers, so you should be able to loop over the names and store them in a variable (_not_ column) something like this:
> >
> > qui dstdize freq pop sex agegp, by(sla) using (t0)
> >
> > drop _all
> > return list
> > matrix C = r(crude)', r(adj)', r(lb)' , r(ub)'
> > svmat C, names(col)
> >
> > gen rowname = .
> > qui forval i = 1/95 {
> >        replace rowname = r(c`i') in `i'
> > }
> >
> > Nick
> > [email protected]
> >
> > Judy You
> >
> > I am running a "dstdize" age-standardised rate syntax and got a result
> > with Crude and age-adjusted rate, together with lower and upper limit.
> >
> > The age adjusted rate is reported by SLA level (which there are 95
> > rows or records). I have save the matrix in a file but the result
> > doesn't come along with SLA code. I could force it to do by merge the
> > predefined file with sla code to the one saved in the matrix. I
> > believer there should be the smart way to do.
> >
> > Here is my log file. Thanks for your help in advance!
> >
> > ----------
> >
> > . qui dstdize freq pop sex agegp, by(sla) using (t0)
> >
> > . drop _all
> >
> > . return list
> >
> > scalars:
> >                  r(k) =  95
> >
> > macros:
> >                 r(by) : "sla"
> >                r(c95) : "`"5050"'"
> >                r(c94) : "`"5000"'"
> >                r(c93) : "`"4809"'"
> > ------
> >                 r(c3) : "`"205"'"
> >                 r(c2) : "`"203"'"
> >                 r(c1) : "`"201"'"
> >
> > matrices:
> >                 r(se) :  1 x 95
> >                 r(ub) :  1 x 95
> >                 r(lb) :  1 x 95
> >                r(adj) :  1 x 95
> >              r(crude) :  1 x 95
> >               r(Nobs) :  1 x 95
> >
> > . matrix C = r(crude)', r(adj)', r(lb)' , r(ub)'
> >
> > . svmat C, names(col)
> > number of observations will be reset to 95 Press any key to continue,
> > or Break to abort obs was 0, now 95
> >
> > . save t1,replace
> > file t1.dta saved
> >
> > Crude   Adjusted        Left    Right
> > .0144418        .0213993        .0160632        .0267354
> > .0242798        .0409689        .030746 .0511917
> > .0123417        .0186174        .0149574        .0222773
> > .0097357        .0142612        .0108197        .0177028
> > .0260393        .051086 .0389991        .0631729
> >
> > -----
> >
> >
> > The saved file looks like that, but what I like is to have a column
> > named as SLA, corresponding to the SLA codes in the original data.
> > Could any expert give me some hint?
> >
> >
> > *
> > *   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index