Statalist


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

RE: st: Query on how to re-link variables to their original name tag after mkmat and svmat manipulations


From   Roy Wada <roywada@hotmail.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Query on how to re-link variables to their original name tag after mkmat and svmat manipulations
Date   Tue, 25 Aug 2009 08:53:34 -0700

I have been told the earlier post was too vague. These codes 
will save a "my_secret_secret" file, which can be used to get the 
string names back after -svmat-.
 
 
sysuse auto, clear
encode make, gen(make_coded)
 
preserve
keep make make_coded
sort make_coded
save my_secret_secret, replace
restore
 
* arbitarily mix them
sort price, stable
 
* do your stuff
mkmat make_coded mpg, mat(results)
mat list results
drop *
svmat results
 
* this preserves the desired presentation order
gen id=_n
 
* merge
ren results1 make_coded
sort make_coded
merge make_coded using my_secret_secret
 
* this restores the desired presentation order 
sort id
drop id _merge
 
_________________________________________________________________
Get back to school stuff for them and cashback for you.
http://www.bing.com/cashback?form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_BackToSchool_Cashback_BTSCashback_1x1
*
*   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