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

st: Transforming numeric to categorical (not to string!) variables

From   TEWODAJ MOGUES <[email protected]>
To   Stata _ <[email protected]>
Subject   st: Transforming numeric to categorical (not to string!) variables
Date   Tue, 10 Aug 2004 19:22:08 -0400

Dear Statalisters,

Here's something I've been trying to figure out for a while, even though it seems so straightforward. How do I take a regular numerical variable called COLOUR that takes on the values 1, 2, and 3, and change it into a categorical variable so that 1 becomes "green", 2 becomes "blue" and 3 "white"? I.e. when viewing the data in the data editor, say, I want to see the colour names and not the numbers. And yet if I were, say, to type 
    sum colour
I want it to give me as the min "1, the max "3", the mean and etc. So I don't want to make the variable a string variable. 

A related question: Once I have achieved that, is there a way I can make the data editor window show me the number values instead of the name values of such categorical variables. That is, is there a way to toggle between one view and the other? SPSS, which is in many other ways of course inferior to stata, does however have such a toggle option that stata doesn't seem to have.

Thanks much!

Tewodaj Mogues
Dept. of Agricultural and Applied Economics
University of Wisconsin - Madison
427 Lorch St. #317, Taylor Hall
Madison, WI 53706

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index