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

Re: st: string function problem


From   Joseph Coveney <[email protected]>
To   Statalist <[email protected]>
Subject   Re: st: string function problem
Date   Wed, 20 Aug 2003 12:52:19 +0900

Ricardo Ovaldia asked about the formated -string()- function:

--------------------begin excerpted post---------------------------------

. gen y=string( a1,"%16")
(5 missing values generated)

What I'm doing wrong? -y- is missing everywhere.

---------------------end excerpted post-----------------------------------

The formatted string function needs to have the format specified as a
numeric type, that is, "%16.0f" and not "%16".

Joseph Coveney


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

. do "A:\string.do"

. clear

. input float rec long a1

           rec            a1
  1.   1.         12345678
  2.   2.         12345679
  3.   3.         12345678
  4.   4.         12345678
  5.   5.         12345679
  6. end

. generate y = string( a1,"%16.0f")

. slist

     rec        a1         y
  1.   1  12345678  12345678
  2.   2  12345679  12345679
  3.   3  12345678  12345678
  4.   4  12345678  12345678
  5.   5  12345679  12345679

. exit

end of do-file

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




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