IDEAS home Printed from https://ideas.repec.org/p/boc/usug13/01.html
   My bibliography  Save this paper

Creating factor variables in resultssets and other datasets

Author

Listed:
  • Roger Newson

    (National Heart and Lung Institute, Imperial College London)

Abstract

Factor variables are defined as categorical variables with integer values, which may represent values of some other kind, specified by a value label. We frequently want to generate such variables in Stata datasets, especially resultssets, which are output Stata datasets produced by Stata programs such as the official Stata statsby command and the SSC packages parmest and xcontract. This is because categorical string variables can only be plotted after conversion to numeric variables and because these numeric variables are also frequently used in defining a key of variables, which identify observations in the resultsset uniquely in a sensible sort order. The sencode package is downloadable, and frequently downloaded, from SSC and is a “super†version of encode, which inputs a string variable and outputs a numeric factor variable. Its added features include a replace option allowing the output numeric variable to replace the input string variable, a gsort() option allowing the numeric values to be ordered in ways other than the alphabetical order of the input string values, and a manyto1 option allowing multiple output numeric values to map to the same input string value. The sencode package is well established and has existed since 2001. However, some tips will be given on ways of using it that are not immediately obvious but which the author has found very useful over the years when mass-producing resultssets. These applications use sencode with other commands, such as the official Stata command split and the SSC packages factmerg, factext, and fvregen.

Suggested Citation

  • Roger Newson, 2013. "Creating factor variables in resultssets and other datasets," United Kingdom Stata Users' Group Meetings 2013 01, Stata Users Group.
  • Handle: RePEc:boc:usug13:01
    as

    Download full text from publisher

    File URL: http://repec.org/usug2013/newson.uk13.pdf
    File Function: presentation materials
    Download Restriction: no

    File URL: http://repec.org/usug2013/newson_examples1.do
    File Function: sample file
    Download Restriction: no
    ---><---

    References listed on IDEAS

    as
    1. Roger B. Newson, 2012. "From resultssets to resultstables in Stata," Stata Journal, StataCorp LP, vol. 12(2), pages 191-213, June.
    2. Roger B. Newson, 2012. "Sensible parameters for univariate and multivariate splines," Stata Journal, StataCorp LP, vol. 12(3), pages 479-504, September.
    3. Roger Newson, 2010. "Post-parmest peripherals: fvregen, invcise, and qqvalue," United Kingdom Stata Users' Group Meetings 2010 01, Stata Users Group.
    4. Roger Newson, 2004. "From datasets to resultssets in Stata," United Kingdom Stata Users' Group Meetings 2004 16, Stata Users Group.
    Full references (including those not matched with items on IDEAS)

    Citations

    Citations are extracted by the CitEc Project, subscribe to its RSS feed for this item.
    as


    Cited by:

    1. Roger Newson, 2022. "Resultssets in resultsframes in Stata 16-plus," London Stata Conference 2022 01, Stata Users Group.
    2. Roger B. Newson, 2023. "Customized Markdown and .docx tables using listtab and docxtab," UK Stata Conference 2023 01, Stata Users Group.

    Most related items

    These are the items that most often cite the same works as this one and are cited by the same works as this one.
    1. Roger Newson, 2022. "Resultssets in resultsframes in Stata 16-plus," London Stata Conference 2022 01, Stata Users Group.
    2. Roger B. Newson, 2023. "Customized Markdown and .docx tables using listtab and docxtab," UK Stata Conference 2023 01, Stata Users Group.
    3. Javier Alejo & Gabriel Montes-Rojas & Walter Sosa-Escudero, 2023. "RIF regression via sensitivity curves," Statistical Methods & Applications, Springer;Società Italiana di Statistica, vol. 32(1), pages 329-345, March.
    4. Charalampos Agiropoulos & Michael L. Polemis & Michael Siopsis & Sotiris Karkalakos, 2022. "Revisiting the finance‐growth nexus: A socioeconomic approach," International Journal of Finance & Economics, John Wiley & Sons, Ltd., vol. 27(3), pages 2762-2783, July.
    5. Polemis, Michael L. & Stengos, Thanasis & Tzeremes, Nickolaos G., 2020. "Revisiting the impact of financial depth on growth: A semi-parametric approach," Finance Research Letters, Elsevier, vol. 36(C).
    6. Checherita-Westphal, Cristina & Žďárek, Václav, 2017. "Fiscal reaction function and fiscal fatigue: evidence for the euro area," Working Paper Series 2036, European Central Bank.
    7. Minzhi Wu & Emili Tortosa-Ausina, 2020. "Bank Diversification and Focus in Disruptive Times: China, 2007–2018," Working Papers 2020/21, Economics Department, Universitat Jaume I, Castellón (Spain).
    8. Roger Newson, 2014. "Easy-to-use packages for estimating rank and spline parameters," United Kingdom Stata Users' Group Meetings 2014 01, Stata Users Group.
    9. Roger Newson, 2017. "Ridit splines with applications to propensity weighting," United Kingdom Stata Users' Group Meetings 2017 01, Stata Users Group.
    10. Halkos, George & Polemis, Michael, 2018. "Does market structure trigger efficiency? Evidence for the USA before and after the financial crisis," MPRA Paper 84511, University Library of Munich, Germany.
    11. Michael L. Polemis, 2018. "Revisiting the Environmental Kuznets Curve: a semi-parametric analysis on the role of market structure on environmental pollution," Letters in Spatial and Resource Sciences, Springer, vol. 11(1), pages 27-35, March.
    12. Maarten L. Buis, 2017. "Not All Transitions Are Equal: The Relationship Between Effects on Passing Steps in a Sequential Process and Effects on the Final Outcome," Sociological Methods & Research, , vol. 46(3), pages 649-680, August.
    13. Roger Newson, 2020. "From datasets to metadatasets in Stata," London Stata Conference 2020 01, Stata Users Group.

    More about this item

    Statistics

    Access and download statistics

    Corrections

    All material on this site has been provided by the respective publishers and authors. You can help correct errors and omissions. When requesting a correction, please mention this item's handle: RePEc:boc:usug13:01. See general information about how to correct material in RePEc.

    If you have authored this item and are not yet registered with RePEc, we encourage you to do it here. This allows to link your profile to this item. It also allows you to accept potential citations to this item that we are uncertain about.

    If CitEc recognized a bibliographic reference but did not link an item in RePEc to it, you can help with this form .

    If you know of missing items citing this one, you can help us creating those links by adding the relevant references in the same way as above, for each refering item. If you are a registered author of this item, you may also want to check the "citations" tab in your RePEc Author Service profile, as there may be some citations waiting for confirmation.

    For technical questions regarding this item, or to correct its authors, title, abstract, bibliographic or download information, contact: Christopher F Baum (email available below). General contact details of provider: https://edirc.repec.org/data/stataea.html .

    Please note that corrections may take a couple of weeks to filter through the various RePEc services.

    IDEAS is a RePEc service. RePEc uses bibliographic data supplied by the respective publishers.