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

st: RE: RE: RE: Strings and the greater than/less than operators

From   "Nick Cox" <>
To   <>
Subject   st: RE: RE: RE: Strings and the greater than/less than operators
Date   Wed, 13 May 2009 18:14:17 +0100

I wrote -char()-, not -char-. The () signal a function, -char()-. For

. di char(65)

. di char(97)

Referring to -char()- is more precise than referring to (say) ASCII
order, which doesn't mean the same thing in absolutely all

Stata doesn't offer an inverse to -char()-, but -asciiplot- from SSC
gives you a graphical display of the characters on your system. In any
case, typing e.g.  

di ("a" > "A") 

gives you 1 for true and 0 for false. 

Incidentally, these data look like first parts of UK postcodes. Right or
wrong, you might use -trim()- to lose the trailing spaces now in order
not to be bitten again. 




Thanks Nick...and, of course, you're dead right.  

The giveaway, I realise now, is the alignment of the values of code
the heading 'code' in the tabulation.  I think that the last character
aligns vertically with the 'e' of 'code'.

The only bit I don't understand is: "The order is that of -char()-".  

It sounds to me as if char is user defined.  This is from the help for

 The dataset itself and each variable within the dataset have associated
with them a set of characteristics.
    Characteristics are named and referred to as varname[charname],
varname is the name of a variable or _dta.
    The characteristics contain text.  Characteristics are stored with
dataset in the Stata-format .dta dataset,
    so they are recalled whenever the dataset is loaded.

If characteristics for a variable are not defined by the user, what's
default order?  Is there a list somewhere which will tell me the order
which Stata sorts characters e.g. alphabetric, numeric, spaces, etc.  Or
I misinterpreting here?

Once again, thanks for your help.

Nick Cox

General question: Absolutely. The order is that of -char()-. 

Specific question: "N05 " > "N05". You have trailing spaces. They are
characters too. 



Can the greater than (>) and less than (<) operators be applied to

If the answer is 'yes' (as I thought), why is "N05" included in the
for the following command? 

. tab code admimeth if (admimeth==31 | admimeth==32) & (code>"N05" &

           |       admimeth
      code |        31         32 |     Total
      N05  |       103        163 |       266 
      N06  |    23,858        132 |    23,990 
      N07  |   364,687      2,653 |   367,340 
      N08  |     8,079         18 |     8,097 
      N09  |    70,953        132 |    71,085 
      N10  |    24,606         88 |    24,694 
      N11  |   123,635        256 |   123,891 
      N12  |   546,148     21,998 |   568,146 
     Total | 1,162,069     25,440 | 1,187,509 

*   For searches and help try:

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