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" <[email protected]>
To   [email protected]
Subject   Re: st: Some kind of count or tabulation
Date   Fri, 06 Jan 2006 14:59:17 +0000

thank you svend, your egen suggestion worked. in fact earlier on, at the stage of inputting the data, i have indeed used many -replace var if- in a do-file to replace blanks with a period before running my small do-file to count but i appreciate your -foreach- help suggestion.

regards,
bw

ps: i would not have thought what i wanted would be an egen function. instinctively i thought it would be either some kind of count or tabulation.


From: "Svend Juul" <[email protected]>
Reply-To: [email protected]
To: <[email protected]>
Subject: Re: st: Some kind of count or tabulation
Date: Fri, 6 Jan 2006 14:12:07 +0100

B. Water:

I understand that your var1-varn are string variables. For strings, the
missing value typically is a blank, not a period, so I would first:

   foreach V of varlist var1-varn {
     replace `V'="" if `V'=="."
   }

If you feel unsecure about the above construct, you might instead give
as many replace commands as you have variables:
   replace var1="" if var1=="."
   ...

Now you can use egen's robs() function with the strok option:
   egen nonmiss = robs(var1-varn) , strok

In Stata 9 the robs() function got the more telling name rownonmiss().

Now, the variable -nonmiss- tells the number of nonmissing (i.e.
non-blank) values for each observation. Wasn't that what you were
looking for?

Hope this helps
Svend

__________________________________________

Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6
DK-8000  Aarhus C, Denmark
Phone: +45 8942 6090
Home:  +45 8693 7796
Email: [email protected]
__________________________________________

*
*   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/
_________________________________________________________________
Is your PC infected? Get a FREE online computer virus scan from McAfee� Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963

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