[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: counting per index
I guess there is a easy solution for this, but after looking at it for a couple of hours I and searching the internet for the solution I still haven't found it. Now my mind is completely lost somewhere, so I hope any of you can help me out.
I have a variable -limit- with limits. e.g.
And there is variable for instance called -x- with other values e.g.
What I want is a new variable which has on index i the counts of -x-'s smaller than the -limit- on that index. So for index 1 I want to count the number of values which are smaller than limit = 2. In this case values 0,1 and -3 of -x- are smaller, so I want to have 3 on index 1 in my new variable.
For index 2, only values 0 and -3 are smaller than limit=1, so I want a 2 there.
I tried summing over a variable with ones which didn't seem to work...
(for instance: gen nsmall = sum(ones) if x < limit[_n])
Any other suggestions?
This email message is for the sole use of the intended recipient(s) and
may contain privileged information. Any unauthorized review, use,
disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply email and destroy all copies
of the original message.
* For searches and help try: