Statalist


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

Re: st: data management - changing every 1st encountered of a str data content of a var


From   Steven Samuels <[email protected]>
To   [email protected]
Subject   Re: st: data management - changing every 1st encountered of a str data content of a var
Date   Tue, 6 Jan 2009 21:51:55 -0500

I see why you thought that. BW implied that it did come in pairs. Perhaps it should, but I'm not sure how he can know that it does.

-Steve
On Jan 6, 2009, at 9:45 PM, Ashim Kapoor wrote:

ahhhh  I see. I was thinking diathermy only occured in pairs and that
I could assume that.

Thank you,
Ashim.

On Wed, Jan 7, 2009 at 7:38 AM, Steven Samuels <[email protected]> wrote:
It will not uniquely identify the first occurrence there are triplets or
longer runs. How would an analyst know there are none?

-Steve


On Jan 6, 2009, at 8:00 PM, Ashim Kapoor wrote:

i think it does identify the first occurance,
here is the output


    +---------------------------------------------+
    |                 var1                      j |
    |---------------------------------------------|
 1. |            monopolar              monopolar |
 2. |              bipolar                bipolar |
 3. |              bipolar                bipolar |
 4. |              bipolar                bipolar |
 5. |            monopolar              monopolar |
    |---------------------------------------------|
 6. |            nodiathrm              nodiathrm |
 7. |         diathermy[2]           diathermy[1] |
 8. |         diathermy[2]           diathermy[2] |
 9. |              bipolar                bipolar |
 10. |            monopolar              monopolar |
    |---------------------------------------------|
 11. |         diathermy[2]           diathermy[1] |
 12. |         diathermy[2]           diathermy[2] |
 13. |                    .                      . |
 14. | . <- denotes missing   . <- denotes missing |
 15. |                    .                      . |
    |---------------------------------------------|
 16. |            monopolar              monopolar |
 17. |         diathermy[2]           diathermy[1] |
 18. |         diathermy[2]           diathermy[2] |
 19. |                    .                      . |
 20. |                    .                      . |
    +---------------------------------------------+

no ??

Thank you,
Ashim
On Tue, Jan 6, 2009 at 6:20 PM, Ashim Kapoor <[email protected]>
wrote:

I would do: -

Suppose your variable is called var


gen j=var
replace j="diathermy[1]" if j[_n+1]=="diathermy[2]" & j=="diathermy[2]"

Then j would have what you want.

I think this should do it.

Thank you,
Ashim.

ue, Jan 6, 2009 at 1:22 PM, b. water <[email protected]> wrote:

dear all,

stata 8.2 xp pro,

i have a var like this:

monopolar
bipolar
bipolar
bipolar
monopolar
nodiathrm
diathermy[2]
diathermy[2]
bipolar
monopolar
diathermy[2]
diathermy[2]
.
. <- denotes missing
.
monopolar
diathermy[2]
diathermy[2]
.
.

what i want to achieve is for every first encountered diathermy [2] to be changed to diathermy[1], while leaving the second occurence as diathermy[2]. is this possible in stata? if it can be done, would appreciate advice/help
on how to achieve it.

thank you,
bw
_________________________________________________________________
It's the same Hotmail(R). If by "same" you mean up to 70% faster.

http://windowslive.com/online/hotmail? ocid=TXT_TAGLM_WL_hotmail_acq_broad1_122008
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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