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

Re: st: Re: destringing


From   Suzy <[email protected]>
To   [email protected]
Subject   Re: st: Re: destringing
Date   Sat, 28 Aug 2004 12:18:10 -0400

Dear Scott - Your advice works!...I completely forgot about the quotations required for string variables...I use them all the time to create titles and labels. But frankly, I've never encountered string variables since using Stata.

Since these 11 variables were created as string varibales - I can do it your way now for all the datapoints within the variable (numeric and alpha-numeric and dashes) as long as I've enclosed the value within quotations. This is clear to me My follow-up question is this:
Since the majority of the datapoints are actually numeric rather than alpha-numeric...is there a way for me to modify the 11 variable (dxcodes and procodes) from string to numeric and then modify the alpha-numeric datapoints within that variable to be read as either a string or numeric (I don't care which as long as it can be read)... and as the other gentlemen had stated - it's probably best to retain the code as is rather than drop the dashes and alphabets.

Thanks so much for a simple and overlooked solution!
Regards,
Suzy

Scott Merryman wrote:


-----Original Message-----
From: [email protected] [mailto:owner-
[email protected]] On Behalf Of Suzy
Sent: Saturday, August 28, 2004 10:30 AM
To: [email protected]
Subject: Re: st: Re: destringing

<snip>



But then , trying to analyze anything with the dxcode or procode
variable name returned this type of output:

. tab dxcode1 if dxcode1==V3000
V3000 not found
r(111);

I also tried this:

tab dxcode1 if dxcode1==v3000
v3000 not found
r(111);

And this....

tab dxcode1 if dxcode1==27500 (just numeric)
type mismatch
r(109);

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.


Since dxcode1 is a string variable the value following the if qualifier must
be enclosed in quotes

- tab dxcode1 if dxcode1=="V3000" -

Or if the codes are in lower case:

- tab dxcode1 if dxcode1=="v3000" -

In Stata, capitalization matters V3000 and v3000 would be treated as
different values.


Scott

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




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



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