Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Some kind of count or tabulation?


From   "b. water" <barleywater@hotmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Some kind of count or tabulation?
Date   Fri, 06 Jan 2006 11:04:02 +0000

thanks to nick and scott for their replies. i understand what scott tried to do but looking at his commands made me realised that perhaps he, and by extension also nick too, misunderstood my question, which could be better expressed in retrospect. i have less of an understanding of nick's commands since it has something to do with macros (afraid my stata fluency don't go that far yet).

however, running scott's command viz-a-viz nick's showed a difference of 1, e.g. scott's would return a value of 78 whilst nick's 77. i am not sure why that is the case. be that as it may, neither was what i was looking for. so thinking laterally, using what i knew of stata, here's what i did to get what i want.

gen dumvar1=.
gen dumvar2=.
.
.
.
sort var1
by var1: replace dumvar1 = 1 if var1 == "jacn"
by var1: replace dumvar1 = 1 if var1 == "bstr"
sort dumvar1
replace dumvar1 = 0 if dumvar1==.
.
.
.
sort var2
by var2: replace dumvar2 = 1 if var2 == "clstr"
by var2: replace dumvar2 = 1 if var2 == "rct"
by var2: replace dumvar2 = 1 if var2 == "xovr"
sort dumvar2
replace dumvar1 = 0 if dumvar1==.
.
.
gen total = var1 + var2 +...
sort total
l obs total

but...

1. not elegant (not a problem since it does the job)
2. it loses the information the variables conveyed by replacing with 1's (not ideal)
3. initially at least it looked like amadou's tablemat would be helpful but unfortunately it was not

so...

would appreciate (if nothing else, for my own stata's education now) further help/advice to shorten the do-file if possible (i think it needed -foreach val- at the beginning).

regards,
bw




From: smerryman@kc.rr.com
Reply-To: statalist@hsphsun2.harvard.edu
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: Some kind of count or tabulation?
Date: Thu, 05 Jan 2006 14:33:03 -0600

-egen all_var = rmiss(Var*)-

-count if all_var == 0 -


Scott


----- Original Message -----
From: "b. water" <barleywater@hotmail.com>
Date: Thursday, January 5, 2006 2:09 pm
Subject: st: Some kind of count or tabulation?

> Dear all,
>
> Stata 8.2 Windows XP Pro SP2
>
> My data set looks like this:
>
> obs	Var1	Var2	Var3	Var(nth)
> 1	jacn	clstr	lnreg	pval
> 2	bstr	.	lgreg	nopval
> 3	.	rct	.	nopval
> 4	jacn	clstr	anova	.
>
> What I want to do firstly is to count frequencies of features in
> each
> variable, which I did with tab1 varlists. Then what I want to find
> out is
> simply how many observations contained all the variables, e.g. in
> this
> example, only 1 observation i.e. the first (observation 1)
> contained all the
> variables. I think it has something to do with tabulate but just
> couldn't
> get the syntax for this. Any help/advise is appreciated.
>
> Regards,
> bw
>
*
*   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/
_________________________________________________________________
Donít just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/

*
* 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–2021 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index