BookmarkSubscribeRSS Feed
srujanaparcha
Calcite | Level 5

Hello,

   I am beginner in SAS.   I was trying to import a .csv file using IMPORT command using code

PROC IMPORT DATAFILE="D:\work\octbr\problemex\sample.csv"

OUT=marks

DBMS=CSV

REPLACE;

RUN;

Its showing the error that the import file is failed.

I tried many ways to import but failed to import....

Please suggest me how to clear the error and import the data file...

Thanks in advance

Srujana

6 REPLIES 6
srujanaparcha
Calcite | Level 5

this is my sample file data

abcd-AA-45,-0.054829956,-0.046428462,26,29,33,26,41

abcd-AA-44,0.072182266,0.075878166,22,39,34,17,37

abcd-AA-41,-0.242498969,-0.183132623,17,29,32,31,22

abcd-AA-34,0.119176859,0.184544889,26,44,33,14,39

abcd-AA-31,-0.163328092,-0.048343209,34,33,31,18,31

abcd-AA-25,-0.181906429,-0.25667866,23,24,25,22,28

abcd-AA-24,-0.197937552,-0.074703951,26,33,36,19,37

abcd-AA-22,-0.102977317,0.152645372,32,32,32,23,33

abcd-AA-13,0.187188343,-0.023572483,20,33,30,16,41

I have written the following code

PROC IMPORT DATAFILE="D:\work\octbr\problemex\sample.csv"

OUT=marks

DBMS=CSV

REPLACE;

GETNAMES=yes;

RUN;

PROC PRINT DATA=marks;

RUN;

And this is the error report generated

ERROR: Import unsuccessful. See SAS Log for details.

NOTE: The SAS System stopped processing this step because of errors.

NOTE: PROCEDURE IMPORT used (Total process time):

  real time 0.09 seconds

  user cpu time 0.03 seconds

  system cpu time 0.02 seconds

  memory 8928.50k

  OS Memory 32004.00k

  Timestamp 11/13/2014 08:57:49 AM

  Step Count 7 Switch Count 49

  Page Faults 0

  Page Reclaims 2724

  Page Swaps 0

  Voluntary Context Switches 228

  Involuntary Context Switches 27

  Block Input Operations 0

  Block Output Operations 72

  

64 PROC PRINT DATA=marks;

ERROR: File WORK.MARKS.DATA does not exist.

65 RUN;

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Sorry, gonna sound like a broken record here, but I would advise to use datastep code to read in any file.  With proc import you are letting SAS guess what should be done.  It should be the other way round, you, who knows the data, should tell SAS what to import.  The code below gives exactly the same output, and can be manipulated:

data want;

  length var1 $200.;

  infile "s:\temp\rob\a.csv" dlm="," missover dsd lrecl=32767;

  input var1 $ var2 var3 var4 var5 var6 var7;

run;

Kurt_Bremser
Super User

If that is your file (and you have not omitted the first line), then getnames=yes is, of course, wrong.

Without a line containinmg column names, you are much better off with a manually written data step.

You're better off with a data step, anyway; I strongly second RW9 here. PROC IMPORT may tolerate erroneous data that will cause ERRORs later on (like character data in a column that is expected to be numeric)

arodriguez
Lapis Lazuli | Level 10

Try with this code

PROC IMPORT DATAFILE="D:\work\octbr\problemex\sample.csv"

OUT=marks

DBMS=CSV

REPLACE;

GETNAMES=NO;

GUESSINGROWS=1000;

RUN;

If your data is like your sample, you must put getnames=NO since it doesn't have a column name. Also I have added guessingrows that produce that SAS import more lines before appling a format.

Peter_C
Rhodochrosite | Level 12

what kind of SAS are you running?

E G, SAS/Studio or base SAS?

On what platform is your sas server running?

Please report the result of running

%put _automatic_ ;

In particular SYSSCP, and SYSSCPL should show if you are running in an environment that can read from "D:\work\octbr\problemex\sample.csv"

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 6 replies
  • 7953 views
  • 3 likes
  • 5 in conversation