Announcement

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

  • import: unknown subcommand "delimited"

    Hi there,

    I am getting an error message and I am not sure why. The folder C:\Users\patrick\Work Folders\Documents\csv contains several csv files which I want to get into stata so I have with lots of help created a loop. We were running it at my friends and it worked fine, now back home i get the error message and I my friend will not be reachable for some time. Any advice would be greatly appreciated.

    Thanks

    Patrick


    . global MY_PATH "C:\Users\patrick\Work Folders\Documents"

    . local files : dir "$MY_PATH\csv" files "*.csv"

    . cd "$MY_PATH\csv"
    C:\Users\patrick\Work Folders\Documents\csv

    . foreach file in `files' {
    2. import delimited `file', clear
    3. gen security_id = upper(substr("`file'",1,3))
    4. gen date_new = date(date, "YMD")
    5. replace date_new = date(date,"DMY") if date_new==.
    6. replace date_new = date(date,"MDY") if date_new==.
    7. format date_new %td
    8. drop date
    9. rename date_new date
    10. recast float px_open
    11. recast float px_high
    12. recast float px_low
    13. recast float px_last
    14. rename px_open open
    15. rename px_high high
    16. rename px_low low
    17. rename px_last close
    18. keep security_id date open high low close
    19. drop if date < date("20160601","YMD")
    20. save temp, replace
    21. use "$MY_PATH\csv\security_returns_file", clear
    22. append using temp
    23. save, replace
    24. }
    import: unknown subcommand "delimited"
    r(198);

  • #2
    Can you tell us what version of Stata you are using? The first three lines out of the about command will do fine, as in this example from my system.
    Code:
    . about
    
    Stata/SE 14.2 for Mac (64-bit Intel)
    Revision 19 Dec 2016
    Copyright 1985-2015 StataCorp LP

    Comment


    • #3
      Hello Willam,

      Here is what I get from the about comand:

      Stata/SE 12.1 for Windows (64-bit x86-64)
      Revision 06 Feb 2012
      Copyright 1985-2011 StataCorp LP

      Comment


      • #4
        The import delimited subcommand was added in Stata 13. You may be able to modify your code to use the older insheet command, with which I am unfamiliar (before my time).

        Comment


        • #5
          Patrick: Please note these points from the FAQ Advice at http://www.statalist.org/forums/help

          6. Why are real names preferred?



          You are asked to post on Statalist using your full real name, including given name(s) and a family name, such as "Ronald Fisher" or "Gertrude M. Cox". Giving full names is one of the ways in which we show respect for others and is a long tradition on Statalist. It is also much easier to get to know people when real names are used.

          If you overlook this on first registration, it is easy to fix. Click on “Contact us” located at the bottom right-hand corner of every page.


          11. What should I say about the version of Stata I use?



          The current version of Stata is 14.2. Please specify if you are using an earlier version; otherwise, the answer to your question may refer to commands or features unavailable to you. Moreover, as bug fixes and new features are issued frequently by StataCorp, make sure that you update your Stata before posting a query, as your problem may already have been solved.

          Comment


          • #6
            Thanks Nick, I am using my real name. I assume you meant I should always show which version I use which I will do from now onwards!

            Comment


            • #7
              Thanks William, I will try to get an update. Thanks for the info!

              Comment


              • #8
                We prefer surnames or family names. That is why you were referred to FAQ Advice #6 Is "GC" a family name?

                Updating is generic advice, but won't help here. You need an upgrade to be able to use import delimited. Only version 13 up will make that possible.
                Last edited by Nick Cox; 30 Dec 2016, 03:15.

                Comment


                • #9
                  To follow on from what Nick wrote, an "update" at no cost would take you from Stata 12.1 06 Feb 2012 to Stata 12.1 23 Jan 2014, but this will not supply the import delimited subcommand. You will need to "upgrade" to Stata 13 or later, which in general will cost money.

                  Again, though, insheet is available in Stata 12.1, and my limited reading of the documentation provided by help insheet suggests it will be a straightforward substitution for import delimited in your case. You will need to specify to insheet that your data are separated by commas.

                  Comment


                  • #10
                    Thank you William, I will give that a try!

                    I will however also upgrade to 14 which I can do at Uni (I am studying) and I hope it is free of charge....

                    Comment

                    Working...
                    X