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

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
Barite | Level 11

You save my day!!!

Thanks a lot.

 

HHC

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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