PROC IMPORT

Comments

3 comments

  • Phil Rack

    Hi Sebastia,

    I was trying something similar previously but unfortunately, I do not think that this is possible.

    As a workaround, I just passed the imported dataset into another data step and then manually modified the format for that given column.

    Alternatively, if you look in the execution log after running your PROC IMPORT statement. You can see the SAS code that gets generated by the PROC IMPORT block. In theory, you could copy this code and manually change the format. You could then paste this into your program and use this instead of the PROC IMPORT statement.

    I hope this helps!

    Thanks,

    Phil Rack

    MineQuest Business Analytics, llc - Tucson, AZ

     

    0
    Comment actions Permalink
  • Sebastia Barcelo

    Hi Phil,

    Thanks for your response, I know that I can take the datastep from the log, but I was trying to create a macro to import all the files in a folder (full database with different structure for different projects), so I need to be able to make it in a standard way.

    Thanks,

    Sebastià

    0
    Comment actions Permalink
  • Russ C

    Hi Sebastia,

    Apologies if I'm missing the point of your question, but one solution might be to import multiple csv files by using wildcards in the FILENAME statement. Then use a datastep rather than calling a PROC IMPORT, like this...

    FILENAME fileRef 'C:/RawData/a*.csv';

    DATA WORK.rawin;
    INFILE fileRef DLM=',' DSD TERMSTR=LF MISSOVER LRECL=32767 FIRSTOBS=2;

    (and then so on with your format, informat and input statements...)

    That would bring every csv file named with a first letter of 'a' into the work.rawin dataset.

    If your filenames were named so that files with a different format had a consistent naming convention, then you could use a different FILENAME reference, with a different wildcard, to import files with a different set of formats/informats in another datastep.

    I'm not entirely sure if this would work for you, but it would save trying to save the default PROC IMPORT settings, which in truth I'm not sure is possible.

    As Phil suggests, if you use the Dataset Import Wizard to bring in one of your csv files (right-click on the library, and select Import Dataset... to launch it), then you can step through to set the formatting for each variable, and then copy and paste the code from a panel in the wizard.  The lazy coder's solution, which is my usual preference.  :)

    Hope this helps, with apologies again if I've completely misunderstood.

    Cheers,

    Russ.

    0
    Comment actions Permalink

Please sign in to leave a comment.