Statalist The Stata Listserver


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

RE: st: data formatting question


From   Philip Ryan <[email protected]>
To   [email protected]
Subject   RE: st: data formatting question
Date   Tue, 14 Feb 2006 14:56:48 +1030

If you don't wish to -reshape-, then the following is a possibility:

bysort id: gen temp = (sum(A) & sum(B) & sum(C))

bysort id: egen ABC = max(temp)

drop temp


Phil


At 07:21 PM 13/02/2006 -0800, you wrote:
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/
Philip Ryan
Associate Professor,
Department of Public Health

Head, Data Management & Analysis Centre
Faculty of Health Sciences

postal address:
Department of Public Health
Mail Drop 511
University of Adelaide 5005
South Australia

location:
Level 6
Bice Building
Royal Adelaide Hospital
North Terrace
Adelaide

tel 61 8 8303 3570
fax 61 8 8223 4075
http://www.public-health.adelaide.edu.au/
CRICOS Provider Number 00123M
-----------------------------------------------------------
This email message is intended only for the addressee(s)
and contains information that may be confidential and/or
copyright. If you are not the intended recipient please
notify the sender by reply email and immediately delete
this email. Use, disclosure or reproduction of this email
by anyone other than the intended recipient(s) is strictly
prohibited. No representation is made that this email or
any attachments are free of viruses. Virus scanning is
recommended and is the responsibility of the recipient.

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