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

Re: st: counting


From   "Dimitriy V. Masterov" <dvmaster@lily.src.uchicago.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: counting
Date   Fri, 12 Dec 2003 12:13:30 -0600 (CST)

Try this. It's probably not the most efficient way, but it should work.

********************************************************************
/* Given a variable named x, this loop will create a variable
named y that will be labeled with the information you want */

gen y=.

local i=1
	while `i'<3 {    /* You should change the 3 to what ever your max
value for x */

		local j=`i'+0.05
		local k=`j'+0.05
		local n=round(`i'/(.05))

		replace y=`n' if x>=`j' & x<`k'
		label define ylbl `n' "`j'<=x<`k' ", modify

	local i=`i'+.05
}

label values y ylbl

tab y
******************************************************************************

DVM



On Fri, 12 Dec 2003, Andreas Aschbacher wrote:

> I have the following dataset in ascii in ascending order:
> 1.549688
> 1.551809
> 1.857859
> 2.032088
> 2.055405
> 2.211566
> 2.36462
> 2.36556
> 2.451005
> 2.464704
> 2.562639
> 2.568022
> 2.575661
> ......                          / always with 5 or 6 places behind comma
> ~500000 values in file /
> /
>
> I'd like to know how many values are between :
>                         1.05  and  1.1                  that means >= 1.05
> and < 1.1    stepwidth = 0.05
> I'd like to know how many values are between :
>                          1.1   and  1.15                that means >= 1.1
> and  < 1.15    stepwidth = 0.05
> I'd like to know how many values are between :
>                          1.15   and  1.2                that means >= 1.15
> and  < 1.2    stepwidth = 0.05
> and so on .........
>
> I can't  get  good results with already discussed method of  - tabulate
> myvar,subpop(var2) -
> because I know results from an Excel-Macro.
> My question is: Is there another method of counting  ?
> any help will be appreciated very much
>
> andreas
>
>
> --
> +++ GMX - die erste Adresse für Mail, Message, More +++
> Neu: Preissenkung für MMS und FreeMMS! http://www.gmx.net
>
>
> *
> *   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/
>

_______________________________________________________________________________
Dimitriy V. Masterov

Work:
Center for Social Program Evaluation
1155 East 60th St. Room 038
Chicago, IL 60637
Work: (773)256-6005
Fax: (773)256-6313

Home:
1312 East 53rd St., Apt.309
Chicago, IL 60615
Mobile: (773)220-2760



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