Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8657019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:25:10+00:00 2026-06-12T15:25:10+00:00

I have dates in a CSV, and this is the first time I am

  • 0

I have dates in a CSV, and this is the first time I am running into this problem that when converting the dates from the CSV to Stata I am getting missing values. I usually use:

I have a variable from Excel, ‘xdate’

gen stata_date = date(xdate, “mdy”)

This usually works, but for this data set I am getting all missing values.

In Excel the format category is Date and the Type is *3/14/2001. Weirdly, when I change the format to custom mm/dd/yyyy (when I go to custom now it is on m/d/yyyy) and then rerun my .DO the dates translate perfectly, but when I restart Stata and run the .DO without this manual change I get all missing values.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T15:25:12+00:00Added an answer on June 12, 2026 at 3:25 pm

    Added: 2012-10-13––Another Stata user pointed out that “mdy” in the date() function should be “MDY”.

    If fixing this error does not solve the problem, examine the CSV file to find out what you are feeding Stata:

    clear
    set obs 1
    gen xdate = "3/14/2001"
    
    split xdate, p("/")
    

    • -split- will complain if there are any non-numeric characters other than “/” in the string date. To see what they are, I recommend Nick Cox’s -charlist- command (from SSC).

    • xdate1, xdate2, and xdate3 should be month, day, and year. You can inspect them with -tab- and -codebook-. After fixing any errors, a fool-proof way of creating the date is:

    gen xmonth = real(xdate1)
    gen xday = real(xdate2)
    gen xyear = real(xdate3)
    gen newdate=mdy(xmonth,xday,xyear)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have a list of dates in excel in the format (this comes originally from
I have data stored in a csv file that looks like this: Date,BLOCK,,Wood,Miscellaneous,,Totals,MO Saturday,4055-RU,4055-AR,4091,1139,1158,,100
I have this code which export data from GridView to csv. It works with
I have a .csv file that I turned into an SQLite database with the
I have CSV data loaded into a multidimensional array. In this way each row
I have lots of dates in a column in a CSV file that I
I have an excel csv with a date/time column and a value associated with
I have two csv file. First File has date offerid clicks orders Second File
I have two dates in javascript: var first = '2012-11-21'; var second = '2012-11-03';
I have two dates: var first = '21-11-2012'; var second = '03-11-2012'; What is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.