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]

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


From   Joe Canner <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: RE: I can't get List to work
Date   Fri, 7 Mar 2014 17:44:15 +0000

Kevin,

I'm not sure I can entirely explain *what* happened, but I think I know *why*.  Your -id- variable is of type long (i.e., numeric) but it looks like you are expecting it to be a string (with a dash in the middle).  Apparently, you have some format applied that inserts the dash into the displayed value, giving the impression that it is indeed a string.  However, when doing comparisons you need to use the actual value not the formatted value.  Accordingly, when you say "if id==846-6" you are actually asking for id==840 (846 minus 6), which seems to correspond to an -id- with a formatted value of 1131-172.  You need to figure out what numeric value of -id- corresponds to a formatted value of "846-6".  Alternatively (and preferably), if you want to treat your -id- variable as a string, you should store it as such.

Regards,
Joe Canner
Johns Hopkins University School of Medicine

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Snapp, Kevin Michael
Sent: Friday, March 07, 2014 12:29 PM
To: [email protected]
Subject: st: I can't get List to work

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.

Any help is appreciated.


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

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