On Aug 28, 2004, at 11:30 AM, Suzy wrote:
. tab dxcode1 if dxcode1==V3000
V3000 not found
r(111);
In your -if- statement, you told Stata to compare the variable
dxcode1 with the variable V3000. And Stata responded: "V3000 not
found" because you don't have a variable called V3000.
And this....
tab dxcode1 if dxcode1==27500 (just numeric)
type mismatch
r(109);
Stata knows from your -infix- command that the data type of
variable dxcode1 is a string (specifically, str5 -- a 5-character
string). You then asked Stata to compare a string variable with a
numerical value -- but since these are different data types, Stata
responded "type mismatch".
That's why I then went ahead and used the destring (and force)
option...which made the dash and alpha-numerics disappear as missing
datapoints - but did allow me to read the pure numeric numbers under
these variable names.
Which seems unnecessary. Have you tried:
tab dxcode1 if dxcode1 == "V3000"
tab dxcode1 if dxcode1 == "27500"
(By the way, are you sure you aren't interested in tabulating the
values of *another* variable when dxcode1 takes on particular values?)
Stata technicians did not tell me that when I added the str5 and str4
to those variables during infix - that my data would not be able to
be read. So this is the full story.
They did not tell you that because that would not be a correct
statement. You can read the data -- and you can use conditional
statements by telling Stata to compare string variables with strings
(i.e. values in "quotes").
Hope this helps.
-- Mike
*
* 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/