Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Another q on formatting dates and highlighted data


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Another q on formatting dates and highlighted data
Date   Fri, 25 Mar 2011 08:39:45 +0000

I guess you are referring to how variables (columns in spreadsheet
language) appear in the Data Editor. By default different colours are
used to make it evident that your variables are  numeric, or numeric
with value labels, or string. Your own question tells you why:
different storage types are needed for different purposes.

Your patient ids are fine as they are, until you need a numeric
equivalent, when you could reach for -encode-. Your dates of birth may
be converted to Stata daily dates by e.g.

gen birth = date(s_birth, "DMY", 2000)
format %td

See help on -dates and times-.

Nick

On Fri, Mar 25, 2011 at 3:30 AM, Tasha Amin <[email protected]> wrote:

> I pasted my data from Excel and now the following columns are highlighted in red and the dates are not accessible the way I need them to be:
> date of birth (entered as "15-Jul-67") and patient id ("A001").
> The variable type for date of birth is str9 with %9s format. How do I get this to be a Stata-readable date so I can calculate age, for example, and so I can read it instantly (so no weird code standing in for 15-Jul-67)? I looked it up online and was not able to convert properly.
> The patient id variable type is str4 with %9s format, as well.
> Also, why are these columns of data in red?

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index