ok, found a solution but would still appreciate advice for alternative way(s) for achieving the desired aim. here's what i did:
first i create a copy variable to protect the original as per nick cox's advice (this is just a simple -gen-), then i -gsort- the copy varlist, which sort missing first and so on. then i list them - make a note of the number of observation when type of injury changes then use -gen- i.e. gen str# newvar = "minimal" in 1/4153, followed by -replace- for the remaining. these get me what i wanted but like i said, would appreciate feedback from others on how the same maybe achieved in different (perhaps less convoluted) ways.
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/
_________________________________________________________________
Connect and share in new ways with Windows Live.
http://www.windowslive.com/share.html?ocid=TXT_TAGHM_Wave2_sharelife_012008
*
* 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/