Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: I can't get List to work


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: I can't get List to work
Date   Fri, 7 Mar 2014 17:45:28 +0000

-list- is working fine. But you are confusing numbers and strings.

What you are thinking of as an "identification number", something like
1131-172, cannot be held by a Stata as a number, as the punctuation
"-" is not part of a number (only digits 0 ... 9, a minus sign, and a
decimal point are allowed).

It can only be held as a string, meaning here as either (a) a value in
a string variable or (b) a value label attached to a numeric variable.

The key here is that by default you see value labels in -list-
whenever your variable has value labels attached, as the -describe-
command tells you it does.

Something you or somebody else did earlier (perhaps an -encode-) means
that the value

840

corresponds to the value label

"1131-172"

I say 840 because 846-6 = 840. When not protected by " ", the
punctuation - is interpreted by Stata as a minus sign, so Stata does
the subtraction before showing you the results of -list-.

To see what is going on, type

list list year satisfaction d_satisfaction id if id == 840

list list year satisfaction d_satisfaction id if id == 840, nola

to see the data with and without the value labels.

If you want to work with a string identifier, read up on the -decode- command.

(By the way, I'd fix that typo "Completly" before someone spots it in
your graphs or tables.)

Nick
[email protected]


On 7 March 2014 17:28, Snapp, Kevin Michael <[email protected]> wrote:
> Hello Stata helpers,
>
> I have a two panel data set.  I set it up with:
>  xtset
>        panel variable:  id (strongly balanced)
>         time variable:  year, 2009 to 2011
>                 delta:  2 units
>
> I have some outliers, d_satisfactin == -4, I'd like to look at so I get a list of them with:
> list satisfaction d_satisfaction id if d_satisfaction == -4
>
> here is a sample of the list:
>            | satisfa~n   d_sati~n         id |
>            |---------------------------------|
> 19084. | Completly         -4   2860-179 |
> 19090. | Completly         -4    2860-30 |
> 26908. | Completly         -4    5154-45 |
>
>
>
> Then I try to look at one by using the id number with:
> list year satisfaction d_satisfaction id if id == 846-6
>
> I get this:
>           +---------------------------------+
>           | satisfa~n   d_sati~n         id |
>           |---------------------------------|
>  1397. |      Very          .   1131-172 |
>  1398. | Completly         -1   1131-172 |
>        +---------------------------------+
>
> That's not the id number i asked for! What gives?
>
> here is the description of id:
> . desc id
>
>               storage   display    value
> variable name   type    format     label      variable label
> ----------------------------------------------------------------------------------
> id              long    %8.0g      id2        Unique Individual ID
>
> if that helps.
>
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index