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

Re: st: Keep string data

From   Ronan Conroy <[email protected]>
To   [email protected]
Subject   Re: st: Keep string data
Date   Fri, 09 Aug 2002 14:42:13 +0100

on 9/8/02 12:00 PM, [email protected] at
[email protected] wrote:

> The 
> variable name is siteterm and is stored at string10 type. When I am
> analysisng the data I need to keep and drop certain cancer sites
> however I am having trouble doing this. I have no problem dropping
> variables that are stored as int and byte types for example
> keep if year==1996
> but when I try to do the following
> keep if siteterm==lung
> I have the error "lung not found; r(111)" returned.

You're going to kick yourself. And I know this for a fact, because I once
spent 2 days going crazy over exactly the same problem in another stats

Stata things that the expression `siteterm==lung' is asking it to test if
the variable siteterm has the same value as the variable lung.

To make it clear to Stata that the argument is a string, enclose it in
double quotes.

. keep if siteterm=="lung"

Note that this will not find "Lung" or "lung ", so tabulate your data to
make sure that site is always spelled the way you think it is.

Ronan M Conroy ([email protected])
Lecturer in Biostatistics
Royal College of Surgeons
Dublin 2, Ireland
+353 1 402 2431 (fax 2329)

And now, Mr President, how about the global alliance against climate change?
*   For searches and help try:

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