Help using Base SAS procedures

PROC Import for csv file truncating last column

Reply
N/A
Posts: 0

PROC Import for csv file truncating last column

Greetings,

I have 6 csv files containing 14 columns that I'm combining into one sas dataset.
If I do files 1-5, all 14 columns are picked up. If I do all 6, I get the following message: "Number of names found is greater than number of variables found." My resulting dataset only contains 13 columns. The last column is dropped.

I've isolated the problem to the 6th file but cannot figure out what this message means. All 6 files have 14 columns and they are all spelled the same. I've searched this site but haven't found anything that details the message.

This is my code

PROC IMPORT OUT= testcsv.csvtest
DATAFILE= "E:\folder1\csv_1.csv"
DATAFILE= "E:\folder1\csv_2.csv"
DATAFILE= "E:\folder1\csv_3.csv"
DATAFILE= "E:\folder1\csv_4.csv"
DATAFILE= "E:\folder1\csv_5.csv"
DATAFILE= "E:\folder1\csv_6.csv"
DBMS=CSV REPLACE;
GETNAMES=YES;
DATAROW=2;
RUN;

Thanks for looking.
Trusted Advisor
Posts: 2,116

Re: PROC Import for csv file truncating last column

Posted in reply to deleted_user
Some things to try.

-- just bring in the 6th file.
-- look at the 6th file with a hex editor. There may be something in there that you can't see with notepad or Word.
-- along the lines of hidden characters, I've had users embed a in the middle of a column and it messed up lots of stuff.
-- did the 6th file come from a Unix source; you could be missing a part of the end-of-line character.
-- it could be the very last row in the 5th file. If it is missing the last field, that might be it.
Ask a Question
Discussion stats
  • 1 reply
  • 440 views
  • 0 likes
  • 2 in conversation