Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • scientific notation on stata

    Hello, I am trying to transfer a datasheet of excel to stata v11, and one of the varible(dateof diagnosis) appears on stata in a exponential form. Where do i have to go, to change this? Thank you for your help.

  • #2
    Is it a pure date, or is it a date and time combination? And what's the variable's name in Stata? I'll call it datevar. Then run
    Code:
    format datevar %td // IF IT'S A DATE ONLY VARIABLE IN EXCEL
    format datevar %tc // IF IT'S GOT BOTH DATE & TIME IN EXCEL
    What's going on is that when you brought in the data from Excel, Stata recognized that it was an Excel date or date-time variable, so it automatically converted it to a corresponding (hopefully--with old versions of Excel this can be pretty funky) Stata internal format date time variable. Stata internal format date time variables are numbers, and, particularly for date-time variables they can be very large numbers. Those very large numbers will be displayed in Stata using scientific notation unless you format them otherwise. The most useful format for a date-time variable is %tc: what Stata displays will then actually read like a date and time to your eyes. For purely date variables, the useful format is %td, which will look to your eyes like a date.

    Regular users of Stata definitely need to learn about how Stata deals with dates and times, the internal representation of them as numbers, the formats that make them easily readable by humans, and the functions for transforming between string variables that look like dates, Stata numeric internal format variables, and assembling dates and times from their components and disassembling them back into components. Study -help datetime- and the corresponding manual section. It's a long and somewhat dizzying read. And none of us remember it all: we all have to refer back to the help files from time to time for details that are hard to remember. But you will find that after a short time, the functions that are most frequently needed for your particular applications will sink in and cease to be sources of difficulty.

    Comment

    Working...
    X