Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: appending or tostring programming issue


From   Joseph Coveney <[email protected]>
To   Statalist <[email protected]>
Subject   Re: st: appending or tostring programming issue
Date   Fri, 22 Sep 2006 11:35:32 +0900

Laura Gibbons wrote:

I have a program that prepares data (and code) for a DOS-based program.
I need a line above the actual data that is of the form:

NPKY      XXXX

with the data below, so it looks like:

NPKY      XXXX
10000000011234
10000000022398
...
etc.

I had done this by creating a one line tempfile with a string variable
with value "NPKY       XXXX" and appending the data file to that file.
Because this first line is in string format, I had to -tostring- the data
as well.  No problem until a user tried a file with 90,000 different
id's;more than the 65,000+ that tostring allows.

Is there a way to generate the header and the data and concatonate them
without using append?  This way I could keep the id's in numeric
format.

Or a way to work around the tostring limitation?

--------------------------------------------------------------------------------

Where did you see that -tostring- has such a limitation?

Joseph Coveney

. clear

. set obs 90000
obs was 0, now 90000

. generate double ID = 10000000000000 + _n

. format ID %14.0f

. tostring ID, generate(id) format(%14.0f)
id generated as str14

. list in -3/l, noobs

 +---------------------------------+
 |             ID               id |
 |---------------------------------|
 | 10000000089998   10000000089998 |
 | 10000000089999   10000000089999 |
 | 10000000090000   10000000090000 |
 +---------------------------------+

. list in 1/3, noobs

 +---------------------------------+
 |             ID               id |
 |---------------------------------|
 | 10000000000001   10000000000001 |
 | 10000000000002   10000000000002 |
 | 10000000000003   10000000000003 |
 +---------------------------------+

. isid id

.

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