Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

st: find categorical variables

From   Jakob Petersen <>
Subject   st: find categorical variables
Date   Thu, 22 Mar 2012 09:02:17 +0000

Looking for a way to distinguish categorical from other types of variables.
The following code is based on the assumption that the mean of a variable of all integers would be an integer, but _rc seems to take the value 7 here regardless - any ideas? Many thanks in advance.

** finding categorical variables ******
sysuse auto,clear
local catvarlist
foreach v of var * {
qui su `v',mean
cap confirm integer number `r(mean)'
if _rc==0 {
local catvarlist `catvarlist' `v'
di "`catvarlist'"
*adapted from:

Jakob Petersen

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index