Announcement

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

  • Error importing date from excel to stata

    Dear Statalist,
    I have a problem when i try to import a date variable (DD/MM/YYYY) from excel to stata.
    Once imported in stata the month and the day are inverted.
    Here an example of my sample in stata
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str13 ISIN str44 ENTREPRISE str22 INFORMATION str10 DATE int YEAR
    "FR0000035784" "DIGIGRAM" "" " 4/16/2010" 2010
    "FR0000062671" "TELEPERFORMANCE" "" " 7/1/2010" 2010
    "FR0000062671" "GORGE" "" " 6/24/2010" 2010
    "FR0000076655" "ACTIA SODIELEC" "" "10/14/2010" 2010
    "FR0000120271" "TOTAL" "" " 1/25/2010" 2010
    "FR0000120578" "SANOFI" "" " 3/31/2010" 2010
    "FR0000121501" "PSA" "" " 4/13/2010" 2010
    "FR0000130395" "REMY COINTREAU" "" " 4/13/2010" 2010
    "FR0010340141" "ADP" "" " 2/5/2010" 2010
    "FR0011010198" "RISC GROUPE" "" " 2/9/2010" 2010
    "FR0013018124" "NICOX" "" " 11/3/2010" 2010
    "FR0013204336" "LDC" "" " 4/22/2010" 2010

    For example the first value for the variable DATE should be 16/04/2010 (16th of april 2010), same thing for the second value it sould be 01/07/2010 (1st of July 2010) and not 7/1/2010.

    Thanks a lot for your time and answers,
    Best regards,



  • #2
    Your real problem is that you need to create a numeric daily date variable to do anything useful, but


    Code:
    gen numdate = daily(DATE, "MDY")
    should work fine and then you can define any congenial format. See

    Code:
    help datetime 
    
    help datetime display format

    Comment


    • #3
      Thank you

      Comment

      Working...
      X