Learning SAS? Welcome to the exclusive online community for all SAS learners.

Error using Proc import

Reply
Contributor
Posts: 31

Error using Proc import

Hi,

I am facing  an error( ERROR: File WORK.MYCSV.DATA does not exist.)

while running the below mentioned code

 

PROC IMPORT DATAFILE='/folders/myfolders/Car_sales.csv';

OUT=WORK.MYCSV
DBMS=CSV
REPLACE;
RUN;

/** Print the results. **/

PROC PRINT DATA=WORK.MYCSV; RUN;

 

COuld you please help me with this.

Super User
Posts: 17,864

Re: Error using Proc import

Post your log. 

 

Remember that SAS Studio is case sensitive on the file name in proc import. 

The best way to make sure the path is correct is to navigate to the file in Files, Folders and Servers pane on right hand side, right click file, select properties and copy path from there. 

Contributor
Posts: 31

Re: Error using Proc import

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 55 56 57 58 /** FOR CSV Files uploaded from Windows **/ 59 60 FILENAME CSV "" TERMSTR=CRLF; 61 62 /** FOR CSV Files uploaded from Unix/MacOS **/ 63 64 FILENAME CSV "" TERMSTR=LF; 65 66 /** Import the CSV file. **/ 67 68 PROC IMPORT DATAFILE='/folders/myfolders/Car_sales.csv'; ERROR: Output SAS data set must be provided. NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE IMPORT used (Total process time): real time 0.01 seconds cpu time 0.00 seconds 69 70 OUT=WORK.MYCSV 71 DBMS=CSV 72 REPLACE; 73 RUN; 74 75 /** Print the results. **/ 76 77 PROC PRINT DATA=WORK.MYCSV; RUN; ERROR: File WORK.MYCSV.DATA does not exist. NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE PRINT used (Total process time): real time 0.02 seconds cpu time 0.02 seconds 78 79 /** Unassign the file reference. **/ 80 81 FILENAME CSV; NOTE: Fileref CSV has been deassigned. 82 83 84 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 96

Super User
Super User
Posts: 7,407

Re: Error using Proc import

You have put a semicolon before the out= statement.   Let me correct your code and also apply some code formatting:

proc import datafile='/folders/myfolders/Car_sales.csv' out=work.mycsv dbms=csv replace;
run;
/** print the results. **/
proc print data=work.mycsv; 
run;

You will note the semicolo appears after the replace only.  Position of that is key.

 

 

Contributor
Posts: 31

Re: Error using Proc import

thanks

 

now having problem in running this

data car5;
set r.car_sales;
where Vehicle_type="Passenger" and Latest_Launch >= '01oct2014'd;
run;

 

 

log

 

 

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
55
56 data car5;
57 set r.car_sales;
NOTE: Data file R.CAR_SALES.DATA is in a format that is native to another host, or the file encoding does not match the session
encoding. Cross Environment Data Access will be used, which might require additional CPU resources and might reduce
performance.
58 where Vehicle_type="Passenger" and Latest_Launch >= '01oct2014'd;
ERROR: WHERE clause operator requires compatible variables.
59 run;
 
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.CAR5 may be incomplete. When this step was stopped there were 0 observations and 15 variables.
WARNING: Data set WORK.CAR5 was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.19 seconds
cpu time 0.18 seconds
 
Super User
Posts: 17,864

Re: Error using Proc import

The errors pretty clear. One of your variables in where clause is the issue. 

 

By compatible variables it means they should be the same type, ie character variables need quotes and date variables need date values. 

 

So run a proc contents on your input data set, r.car_sales, and see what the type and formats are and make sure your where clause is correct. 

 

Things that could be the issue - vehicle type is numeric but has a format applied that allows it to appear as character. In this case you can either find out what the underlying value of the variable is or convert it to character in the where clause. 

Or your date variable is actually a character field. 

Ask a Question
Discussion stats
  • 5 replies
  • 613 views
  • 2 likes
  • 3 in conversation