Proc Import CSV File

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 7
Accepted Solution

Proc Import CSV File

I have a series of CSV Excel with with the same formats.

When I run Proc Import for each file individually:


import datafile='xxxxx\yyyyy.csv'

out = fileone

dbms=csv

;

The format length for a few variables in one of the files changes. There is nothing different in this file.

Is there a way that I can have the import keep the formatted length?

Thanks,


Accepted Solutions
Solution
‎02-21-2013 02:24 PM
PROC Star
Posts: 7,363

Re: Proc Import CSV File

My guess is that some of your files have data that are longer or shorter, for some variables, than your other files.

One workaround, is to run one proc import, press function key 4, and then use that code to import all of the other files.

View solution in original post


All Replies
PROC Star
Posts: 7,363

Re: Proc Import CSV File

Are the culprit formats shorter or longer than the rest of the files?

Occasional Contributor
Posts: 7

Re: Proc Import CSV File

They vary. I wondered about that as well. The other files vary and they are importing without a problem. It is just this file.

Solution
‎02-21-2013 02:24 PM
PROC Star
Posts: 7,363

Re: Proc Import CSV File

My guess is that some of your files have data that are longer or shorter, for some variables, than your other files.

One workaround, is to run one proc import, press function key 4, and then use that code to import all of the other files.

Occasional Contributor
Posts: 7

Re: Proc Import CSV File

Thank you! That worked. I guess there was no way to fix it during the import.

PROC Star
Posts: 7,363

Re: Proc Import CSV File

There is a dbsastype dataset option (e.g., (dbsastype=(y='CHAR(5)'))    ) but, unfortunately, I don't think that it has ever been incorporated into proc import.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 351 views
  • 0 likes
  • 2 in conversation