DATA Step, Macro, Functions and more

Importing issue when csv file has many cell blank

Accepted Solution Solved
Reply
Super Contributor
Posts: 503
Accepted Solution

Importing issue when csv file has many cell blank

[ Edited ]

Hi Everyone,

 

I find that when a scv file has so many initial blank cell,  my SAS code will not import correctly and it cause me trouble as I mentioned in the previous post (https://communities.sas.com/t5/Base-SAS-Programming/Import-issue/m-p/402819#M97858)

 

So I create this sample file and I wish you could help me to import correctly.

 

In this file, the first column has number at the first cell and SAS import the last row correctly.

For the other 2 column (bad1 bad2), many blank cell on top which make SAS import wrong. the value 350 in bad1 (last row) turn to 3. The value 2000 in bad2 turn to 2.

 

By the way, I have to use Import in my work

 

proc import datafile="...\error.csv"
out=error dbms=csv replace;
getnames=yes;
run;

data error; set error;
N=_N_;
if good^=. or bad1^=" " or Bad2^=" ";run;

 

I really appreciate your help.

 

HC

 


Accepted Solutions
Solution
‎10-10-2017 12:35 PM
Super User
Posts: 22,857

Re: Importing issue when csv file has many cell blank

Add a GUESSINGROWS option and make it a big number. Then PROC IMPORT will scan more records before it determines the types. 

This will slow down your processing.

 

proc import datafile="...\error.csv"
out=error dbms=csv replace;
getnames=yes;
guessingrows=1000000;
run;

View solution in original post


All Replies
Solution
‎10-10-2017 12:35 PM
Super User
Posts: 22,857

Re: Importing issue when csv file has many cell blank

Add a GUESSINGROWS option and make it a big number. Then PROC IMPORT will scan more records before it determines the types. 

This will slow down your processing.

 

proc import datafile="...\error.csv"
out=error dbms=csv replace;
getnames=yes;
guessingrows=1000000;
run;
Super Contributor
Posts: 503

Re: Importing issue when csv file has many cell blank

You save my day!!!

Thanks a lot.

 

HHC

☑ This topic is solved.

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

Discussion stats
  • 2 replies
  • 386 views
  • 0 likes
  • 2 in conversation