Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: tostring for large double type variables?


From   Paul Burkander <paul@burkander.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: tostring for large double type variables?
Date   Mon, 8 Aug 2011 14:44:39 -0400

yes, the numbers are just identifiers.  Specifically, they are the
concatenated answers from a multiple choice test.  The test might have
about 45 questions for a given subject, and the answers are 1-5, for
instance.

We receive new files each year with updated test results.  The format
for the files changes quite frequently.  I'm trying my best to come up
with a general system that will append all the files as future files
arrive.  I'm striving to avoid requiring specific coding for specific
problems.  I carefully categorize variables based on whether they can
be easily set to the same type.  For those that can't be, I do a force
destring, but then I lose some information.  I thought it would be
useful to set up an alternative process where instead I change the
"problem" variables to strings, but unfortunately I've run into this
problem.  Ultimately I'd like a general method of reconciling all
variable types across data sets that doesn't require a case-by-case
approach.

Let me know if more clarification would be useful.

Paul

On Mon, Aug 8, 2011 at 12:47 PM, Nick Cox <njcoxstata@gmail.com> wrote:
> As its original author, I am not clear that this is a good use of
> -tostring-, but its -format()- option offers in principle what you
> seek.
>
> You might get better advice if you said more about the data and quite
> how this strange situation occurs. The bottom line is that what you
> intend to do with the variable should have most influence on how it is stored.
>
> At the moment I'm having real difficulty imagining a measurement
> process that yields 45 digits. Is there a decimal point? Are these
> "numbers" just identifiers of some kind?
>
> Nick
>
> On Mon, Aug 8, 2011 at 4:11 PM, Paul Burkander <paul@burkander.com> wrote:
>>  I'm appending files over multiple years where the variable type
>> changes over time.  I have a variable that's a long string of numbers
>> (about 45 numbers) in some years, but which is stored as double in
>> other years.  I'd like to be able to store the variable as either a
>> string or double in the appended file, but I can't figure out a way to
>> use the tostring command that doesn't truncate the double variable.
>>
>>  Is there an easy way to preserve the information and string the variable?
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/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/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index