Statalist


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

st: new string variable which has the formatted value of a variable


From   "Ashim Kapoor" <[email protected]>
To   [email protected]
Subject   st: new string variable which has the formatted value of a variable
Date   Wed, 7 Jan 2009 17:15:04 +0530

Hello everyone,

I am looking for the following, a magic command which would do
something like this , it would create a STRING variable whose CONTENT
is the formatted value of some variable

Why do I need this ?

suppose I have

gen mydate=mdy(m,d,y)

( suppose m=1,d=1,y==2008 in obs 1 )

format %td mydate

gen str magicdate=magicalcommand( mydate )

Then magicalcommand would sense the format of mydate and make the
FIRST observation of magicdate to be 1Jan2008.

Suppose I have a variable j and format %9.5g j
and I only want j upto 2 decimal places then I do replace j =
round(j,.01) but due to precision storage probems I still have more
than 2 decimal places stored in j which stubbornly refuse to go away
even after the use of -float-

I simply do %format9.2f j
then do
gen str magicj=magicalcommand(j)

then i ACTUALLY  have 2 decimal places in j.

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

Why do I need this ? I need to output to an HTML file to make my
output colorful ( thanks to David Elliot's program here  which does
90% of my work by making a table ) which I an unsuccessful at printing
from smcl , and when I write to HTML the ORIGNAL stuff and not it's
FORMAT needs to be the way I output it.

I wonder if such a user written file  exists. I guess if such a
command does not exist I will have to learn to format HTML stuff but I
thought I might ask here first.

Thank you,
Ashim
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index