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

PROC IMPORT OUT= sample1
DATAFILE= "Y:\sample.csv" ;
DBMS=csv REPLACE;
SCANTEXT=YES;
USEDATE=YES;
SCANTIME=YES;
RUN;

Can i use the scan text, usedat and scantime functions

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Editor's Note: This 10-minute tutorial by @Panagiotis shows you how to import CSV files into SAS:

 

 

No, I believe those are specific to other formats. You can use GUESSINGROWS. Set it to MAX and you'll usually get better results.

You do need to specify the DBMS before the semicolon I believe.

 

PROC IMPORT OUT= sample1 
                          DATAFILE= "Y:\sample.csv" 
                          DBMS=CSV 
                          REPLACE;
GUESSINGROWS=MAX;
RUN;

 

https://documentation.sas.com/?docsetId=proc&docsetTarget=n1qn5sclnu2l9dn1w61ifw8wqhts.htm&docsetVer...

 


@Ranjeeta wrote:

PROC IMPORT OUT= sample1
DATAFILE= "Y:\sample.csv" ;
DBMS=csv REPLACE;
SCANTEXT=YES;
USEDATE=YES;
SCANTIME=YES;
RUN;

Can i use the scan text, usedat and scantime functions


 

View solution in original post

9 REPLIES 9
Reeza
Super User

Editor's Note: This 10-minute tutorial by @Panagiotis shows you how to import CSV files into SAS:

 

 

No, I believe those are specific to other formats. You can use GUESSINGROWS. Set it to MAX and you'll usually get better results.

You do need to specify the DBMS before the semicolon I believe.

 

PROC IMPORT OUT= sample1 
                          DATAFILE= "Y:\sample.csv" 
                          DBMS=CSV 
                          REPLACE;
GUESSINGROWS=MAX;
RUN;

 

https://documentation.sas.com/?docsetId=proc&docsetTarget=n1qn5sclnu2l9dn1w61ifw8wqhts.htm&docsetVer...

 


@Ranjeeta wrote:

PROC IMPORT OUT= sample1
DATAFILE= "Y:\sample.csv" ;
DBMS=csv REPLACE;
SCANTEXT=YES;
USEDATE=YES;
SCANTIME=YES;
RUN;

Can i use the scan text, usedat and scantime functions


 

Ranjeeta
Pyrite | Level 9
Thankyou the file im trying to import is very large and therefore the proc import step does not work

Would you be able to suggest how to import it another way?


Reeza
Super User

Not sure how that's possible. I've imported GB text files using PROC IMPORT. 

 

What exactly does 'does not work' mean? Are you getting errors? It starts and doesn't complete?

 

Are you using SAS UE or a full installation of SAS?

 

If SAS UE, it has RAM limitations, but you can add more (VM settings) and you can redirect your work folder to get around some of that.

 


@Ranjeeta wrote:
Thankyou the file im trying to import is very large and therefore the proc import step does not work

Would you be able to suggest how to import it another way?



 

Ranjeeta
Pyrite | Level 9
Im using EG rather than base sas

The file keeps running but there is no import completed

The file size is 1.69 GB


Reeza
Super User
Guessingrows makes it take a long time because it scans the full file first. Try reducing it to a million records or less then. If you have a record layout reading the file using a data step would be significantly faster. I often will read the first million records, build myself a data step (check the log after proc import) and then import the data that way.
ballardw
Super User

@Ranjeeta wrote:
Im using EG rather than base sas

The file keeps running but there is no import completed

The file size is 1.69 GB



EG doesn't matter.

 

The acceptable values for the  option guessingrows is 1 to 2147483647 (or MAX). Unless you have very poor data values around 100000 to 1000000 likely will work. You might want to copy the data step code generated that appears in the log and save it. If you need to set the length of one of your variables larger it may be quicker to set the informat for that variable to a larger length and run the data step with the modified code instead of proc import.

Ranjeeta
Pyrite | Level 9

Thankyou The proc import worked for one of the files it took 20 minutes but I believe there is a difference in speen in base sas vs SAS EG 

ballardw
Super User

@Ranjeeta wrote:

Thankyou The proc import worked for one of the files it took 20 minutes but I believe there is a difference in speen in base sas vs SAS EG 


Yes there is a speed difference because somewhere EG has to use the actual SAS engines. EG is basically just a front end. So there is a little extra time in anything just for EG to talk to the engines. In many places you have EG using SAS on a server, so server performance issues may cause additional delays such as network performance, your user share of processing time or space limits and such.

 

If you have to routinely deal with files of this size you might talk to your SAS Admin about the settings for your access to see if there are settings that could be adjusted for better performance. Perhaps the general IT staff, if any, need to get involved about other system constraints.

Tom
Super User Tom
Super User

@Ranjeeta wrote:

PROC IMPORT OUT= sample1
DATAFILE= "Y:\sample.csv" ;
DBMS=csv REPLACE;
SCANTEXT=YES;
USEDATE=YES;
SCANTIME=YES;
RUN;

Can i use the scan text, usedat and scantime functions


A CSV file is just a text file. Write your own data step to read it.

If you don't have any documentation then look at the top of the file and figure it out yourself.

data _null_;
  infile "Y:\sample.csv"  obs=5;
  input;
  list;
run;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 9 replies
  • 4796 views
  • 4 likes
  • 4 in conversation