BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
hhchenfx
Rhodochrosite | Level 12

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

2 REPLIES 2
Reeza
Super User

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;
hhchenfx
Rhodochrosite | Level 12

You save my day!!!

Thanks a lot.

 

HHC

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 5090 views
  • 1 like
  • 2 in conversation