Announcement

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

  • Importing csv file

    Dear All,

    I am trying to import some data from Kenneth French Data Library (Kenneth R. French - Data Library (dartmouth.edu)). Specifically, I would like to upload in Stata the Fama/French 3 Factors [Weekly] in csv format. I use the following:

    Code:
    copy "https://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/F-F_Research_Data_Factors_weekly_CSV.zip" ff.zip
    unzipfile ff.zip
    import delimited F-F_Research_Data_Factors_weekly.csv
    Importing data was not successful, since I noticed that at the beginning and at the end of the dataset there is a brief description of the dataset. Hence, Stata reads the data as strings putting them in only one column. I tried to use rowrange option but still it did not work.

    Is there any way I can import the data directly in Stata without the need of opening the csv file and deleting the rows that are unnecessary.

    Thanks for your help.

    Dario

  • #2
    Admittedly when I work with Fama French data I open the file and manually delete the note at the end, and I do not know whether it is different now, but before I do not think they were spelling out the name of the date variable...

    To do it automatically, you might try stating what is the delimiter explicitly -help import_delimited##import_delimited_options-, do not know whether it is going to work though.

    Comment


    • #3
      This seems to work:

      Code:
      clear
      copy "https://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/F-F_Research_Data_Factors_weekly_CSV.zip" ff.zip,replace
      unzipfile ff.zip,replace
      import delimited F-F_Research_Data_Factors_weekly.csv,rowrange(6:4931) delimiters("") varnames(5)

      Comment


      • #4
        Joro Kolev Thanks for your reply. Indeed I checked the options and saw the rowrange one in order to specify only the rows containing data, but still the data are imported as string and all in one column. I agree with you that deleting manually the rows that contain the description of the data is easier and possibly I will go for this solution, but my intention is to automate the process in order to stay in Stata enviroment without switching fromo Stata to Excel and viceversa. Thanks anyway for your reply.

        Comment


        • #5
          Ali Atia That was exactly what I needed.

          Comment

          Working...
          X