Statalist The Stata Listserver


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

Re: st: Count presence of item on different vars


From   "Vimalanand S. Prabhu" <[email protected]>
To   [email protected]
Subject   Re: st: Count presence of item on different vars
Date   Mon, 09 Oct 2006 11:23:14 -0400

Hi,

This should work:

gen sum=0
forval i=1/146{
replace sum = sum+1 if v`i'=="4500"
}

Prabhu

Nikolaos A. Patsopoulos wrote:
Hi all,

I've got a set of variables v6-v146, each one containing string values (unique values ~4500):

v6 v7 v8 v9 v10...
text1 text1 text3 text45 text1...
text5 text2 text1 text455 text1
.....

I want to count how many times each of the values appears in at least one of the v6-v146 in each row [observation], e.g. text1 appears at least once in 7365obs.

How can achieve this?


Nikos

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

--
_______________________________________________
Vimalanand S. Prabhu
Ph.D. Candidate
The University of North Carolina at Chapel Hill
CB #3435, Chapel Hill, NC 27599-3435.

1426 MacAlpine Circle
Morrisville, NC 27560.

Tel.: (919) 342 5383 (H), (919) 225 0991 (M).
*
*   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