Statalist


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

Re: st: RE: condensing varlist non-categorical contents to a newvar


From   Philipp Rehm <[email protected]>
To   [email protected]
Subject   Re: st: RE: condensing varlist non-categorical contents to a newvar
Date   Thu, 06 Mar 2008 18:03:19 -0500

.
Your variable injurytype seems to be a string variable.
I haven't looked at how you want to recode it, but if it is a string variable, you will need to use quotation marks ("):

replace injurytype="minimal" if injurytype=="."
or
replace injurytype="minimal" if injurytype==""

It depends on how your missing values are coded.

HTH,
Philipp



b. water wrote:

i tried -replace- to without success e.g.:

. replace injurytype=minimal if injurytype>=.
minimal not found
r(111);

or

. replace injurytype="minimal" if injurytype>=.
type mismatch
r(109);
i have also tried -encode- and -recode- without luck. further advice/help would be appreciated.

regards,
bw


Subject: st: RE: condensing varlist non-categorical contents to a newvar
Date: Thu, 6 Mar 2008 22:02:30 +0000
From: [email protected]
To: [email protected]

As far as I understand this you seem to need the -replace- command. But
create a safe copy of the original first. However, -recode- does apply
more
generally than the examples imply.

b. water

stata 8.2,

i have a variable named injurytype

injurytype
.
.
type II
.
.
none sig
.
.
type III
type III
.
type III and IV
.
.
.
type IV
.
.

i want to reclassify contents of variable injurytype in a new variable
such that the missing values and none sig will be reported as minimal,
type II remain as type II, type III remain as type III, but type III and
IV to be combined with type IV and be reported as major. that is the new
variable (let's call it newvar) would look something like this:

newvar
minimal
minimal
type II
minimal
minimal
minimal
minimal
minimal
type III
type III
minimal
type IV
minimal
minimal
minimal
type IV
minimal
minimal

i tried to look up [R] gen and egen but could not see any that would
help. [R] recode seems to be closest but only applies to categorical
variables. would appreciate advice and help on how to achieve what i
wanted to do.

regards,
bw


_________________________________________________________________
Connect and share in new ways with Windows Live.
http://www.windowslive.com/share.html?ocid=TXT_TAGHM_Wave2_sharelife_012
008
*
* 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/

*
* 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/
_________________________________________________________________
Climb to the top of the charts! Play the word scramble challenge with star power.
http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_jan
*
*   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/

*
*   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