Statalist The Stata Listserver


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

RE: st: data formatting question


From   Andy Choi <[email protected]>
To   [email protected]
Subject   RE: st: data formatting question
Date   Mon, 13 Feb 2006 19:21:42 -0800 (PST)

To clarify my question, here is a new example:
I would like to know if a patient is taking all 3
medications, A, B & C.  The data is formatted so that
each medication forms a new row.

ID#  A   B   C   D   E
1    0   1   0   0   0
1    1   0   0   0   0
1    0   0   1   0   0
2    0   1   0   0   0
2    0   1   0   0   0

I would like to identify all patients who take all 3
medications A, B, and C such as patient 1.  


--- Nick Cox <[email protected]> wrote:

> It seems that "without success" is a new variant on
> that 
> old Statalist standby "doesn't work"! You don't say 
> what you mean by it. 
> 
> These are all legal commands if the data have
> been sorted previously by -countrynumber-. 
> 
> But the first says: within categories of 
> -countrynumber-, -gen new_var- with 
> values of 0. You might as well have said 
> 
> gen new_var == 0 
> 
> as the -by:- prefix makes no difference
> to the result. 
> 
> The same comment applies to the second. 
> 
> Please specify a numerical example showing 
> what you want. 
> 
> Nick 
> [email protected] 
> 
> Andy Choi
>  
> > Using this same example from previous emails is
> there
> > a command that would sort by country number when
> > defining a new variable?
> > 
> > For example, I have tried something like this
> without
> > success:
> > by countrynumber: gen new_var=0
> > by countrynumber: replace new_var=1 if
> year=="1930" &
> > ethnicity=="Hispanic"
> > I want the end result to be 0 or 1 for each unque
> > country number value.  
> > 
> > 
> > > Country Number	year	ethnicity	ethnicpop
> > > 10		1930	Caucasion	1,000,000
> > > 10		1930	Hispanic	50,000
> > > 10		1931	Caucasion	1,000,100
> > > 10		1931	Hispanic	51,000
> > > 11		1931	Asia		10,000
> > >
> > > I want to set up the data so there is only one
> entry
> > > per country per year,
> > > as follows:
> > > 
> > > Country Number	year	ethnic1	   ethnic2   ethpop1
>   
> > > ethpop2
> > > 10		1930	Caucasian  Hispanic  1,000,000	50,000
> > > 
> 
> *
> *   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/
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
*
*   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