Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Michael Stewart <michaelstewartresearch@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: Need help converting values into factor variable |

Date |
Sat, 1 Dec 2012 06:55:18 -0500 |

Dear Statlist reader , I am having trouble converting my values into factor variables and am looking for help. My data looks as follows where "patientid" is pt identification number and "year_elevated" is year in which a particular lab value was elevated patientid year_elevated 111 2009 111 2009 222 2009 222 2011 222 2012 333 2009 333 2012 444 2011 444 2012 555 2009 555 2010 555 2011 555 2012 I want to create a factor variable (y )with values 1= ,2 , 3 and 4 where for each distinct patientid y=1 if year_elevated has anyone of ( 2009 or 2010 or 2011 or 2012) values y=2 if year_elevated has any two of ( 2009 , 2010 , 2011 , 2012) values y=3 if year_elevated has any three of ( 2009 , 2010 , 2011 , 2012) values y=4 if year_elevated has all four of ( 2009 , 2010 , 2011 , 2012) values -- Thank you , Yours Sincerely, Mike. * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: Need help converting values into factor variable***From:*Nick Cox <njcoxstata@gmail.com>

- Prev by Date:
**Re: st: use egen functions to get survey weighted means** - Next by Date:
**RE: st: use egen functions to get survey weighted means** - Previous by thread:
**Re: st: use egen functions to get survey weighted means** - Next by thread:
**Re: st: Need help converting values into factor variable** - Index(es):