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

Re: st: RE: 'if' with labels but finds no observations - sorted!


From   "Paul O'Brien" <[email protected]>
To   [email protected]
Subject   Re: st: RE: 'if' with labels but finds no observations - sorted!
Date   Fri, 23 Apr 2004 21:46:04 +0100

The ncyear (year_f) has the value 2003 and the value label 2003/4

So for the financial year from 1st April 2003

. table ageint if year_f==2003

----------------------
ageint | Freq.
----------+-----------
10 | 1
11 | 1
12 | 7
13 | 12
14 | 99
15 | 325
16 | 700
17 | 960
18 | 1,085
19 | 1,002
20 | 1,213
21 | 1,348


On 23 Apr 2004, at 19:07, Nick Cox wrote:

There is no reason to expect -if- to accept
value labels in this way. Unless explicitly
instructed, -if- deals with values, not
value labels. Thus

if ncyear == 2000/1

is being interpreted as

if ncyear == 2000

as the expression 2000/1 evaluates
to 2000. On the other hand you evidently
have no years that are 2001/2, i.e. 1000.5.

The syntax is

if <exp>

where <exp> denotes an expression, which will
be evaluated before being used.

On the other hand, something like this
should work:

tab ncyear if ncyear == "2000/1":name

Nick
[email protected]

Paul O'Brien

I am not sure what the problem is here, but 'if' is not working for
some date labels.
year_f is OK up to 2000/1 but beyond that give no observations.

.egen year_f = ncyear(date_v), m(4)

. table year_f
----------------------
��year_f |�����Freq.
----------+-----------
�1997/98 |����44,023
�1998/99 |����42,654
��1999/0 |����42,944
��2000/1 |����42,127
��2001/2 |����41,520
��2002/3 |����41,463
��2003/4 |����40,057
----------------------

. table ageint if year_f==2000/1

----------------------
��ageint |�����Freq.
----------+-----------
������12 |���������5
������13 |��������36
������14 |�������131
������15 |�������346
etc

. table ageint if year_f==2001/2

no observations

r(2000);

But there are observations for year_f==2001/2

�. table ageint year_f

--------------------------------------------------------------
----------
-
| year_f
ageint | 1997/98 1998/99 1999/0 2000/1 2001/2 2002/3
2003/4
----------
+--------------------------------------------------------------
10 | 1 1 2
1
1
11 | 2 2 2 1
2
1
12 | 2 3 2 5 4
3
7
13 | 13 20 17 36 22
20
12
14 | 73 49 64 131 110
101
99
15 | 238 259 238 346 362
302
325

If I try -list- I get the same thing:

. list if year_f==2000/1

�Observation 129622

���clin_s~e����������RC���clin_w~k������������������connum����
�������2��
�����date���15-Feb-01��������dob���04-Apr-63

etc


Observation 129623

���clin_s~e����������RC���clin_w~k�������D-
CON�����connum�����������1�������date���07-Feb-01��������dob���06-Apr
-77

etc

. list if year_f==2001/2

This last command gives nothing.

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




Dr Paul O'Brien
Westside Contraceptive Services
Raymede Clinic, Exmoor St, London
W10 6DZ
020 8962 4450 - tel
020 8962 4451 - fax
07900 495 118 - mob




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index