Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: String Problem


From   "David Harrison" <[email protected]>
To   <[email protected]>
Subject   st: RE: String Problem
Date   Thu, 23 Feb 2006 17:11:56 -0000

You do not say what constitutes pain, but I will guess from your example
that it is the presence of the character sequence "D4" anywhere in the
code variable.

In that case, the pain variable can be created with a single string
function:

gen byte pain = strpos(code,"D4")>0

Or

gen byte pain = strmatch(code,"*D4*")

(In Stata 8, replace strpos() with index() and strmatch() with match())

Hope this helps

David

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Raphael
Fraser
Sent: 23 February 2006 16:41
To: [email protected]
Subject: st: String Problem

I have the following string variable code and would like to create the
variable pain. Code is a combination of two digit codes (1 letter,1
number) lumped together as many 6 codes can be combined.

code             pain
Z1D4             1
Y1                 0
H4T2D4F7      1
D4D5             1

I am not sure what combination of string functions to use. Can anyone
help?


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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