Announcement

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

  • Stata cant read date and time and import it as blank cells

    Hi,

    I would like to import an excel sheet of data to Stata. However, the date and time were not imported and Stata showed me blank cells. What is the problem with my excel that Stata cant read it?

  • #2
    We can't comment on what you don't show us. Please show us sample values as shown in MS Excel and the command you used in Stata to import data.

    Code:
    copy and paste data to inside CODE tags as here
    The CODE tags can be typed literally or inserted using the # button in the Advanced Editor. m

    Comment


    • #3
      Click image for larger version

Name:	excel.JPG
Views:	1
Size:	170.9 KB
ID:	1660558

      Click image for larger version

Name:	stata command.JPG
Views:	1
Size:	200.7 KB
ID:	1660559

      Here is the screenshot of the first raws of the excel sheet and the first raws of stata imported data.

      Thank you

      Comment


      • #4


        import excel "C:\other drive\UX\X\ Xmerged data\Xmerged _Final_UPDATED (1).xlsx", sheet("Xmerged _Final_UPDATED") firstrow case(lower)clear
        list patientid acquisitionid acquisitiondateandtimeyyyy acquisition dateandtimeyyyymmddhhmm durations in 1/10

        Comment


        • #5


          import excel "C:\other drive\UX\X\ Xmerged data\Xmerged _Final_UPDATED (1).xlsx", sheet("Xmerged _Final_UPDATED") firstrow case(lower)clear
          list patientid acquisitionid acquisitiondateandtimeyyyy acquisition dateandtimeyyyymmddhhmm durations in 1/10

          Comment


          • #6
            You didn't do all of what I asked. As explained in https://www.statalist.org/forums/help#stata screenshots are of less help than you hope.

            But Stata isn't smart enough to know whether your date-times start month/day or day/month and indeed the header information in column D says that they start with the year, contrary to fact.

            You may need to import everything as string first. Then process dates and times. Presumably other rows in your spreadsheet will clarify the issue of month/day or day/month (look for days 13 to 31 to make that clear).

            Correct spellings are Excel and Stata respectively.

            Comment


            • #7
              THANK YOU!
              I don't know why. However, I wanted to create a sample for here and I copied and pasted 10 raws in another excel and run it with Stata again. then it imported everything. So I decided to copy-paste everything into a new excel sheet and it worked.

              Comment

              Working...
              X