Friday, January 06, 2006

Re: st: Some kind of count or tabulation

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" <SJ@SOCI.AU.DK> >Reply-To: >To: <> >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: >__________________________________________ > >* >* For searches and help try: >* >* >*

_________________________________________________________________ Is your PC infected? Get a FREE online computer virus scan from McAfee´┐Ż Security.

* * For searches and help try: * * *


Links to this post:

Create a Link

<< Home

This page is powered by Blogger. Isn't yours?