Help using Base SAS procedures

ERROR 180-322: Statement is not valid or it is used out of proper order.

Reply
New Contributor
Posts: 3

ERROR 180-322: Statement is not valid or it is used out of proper order.

I'm trying to import an Excel .xlsx file but keep running into a few problems. I didn't write this code and this is my first time using SAS so step by step instructions are the best for me. This code was written for an on computer version of SAS whereas I am using the University Edition. 

The PROC IMPORT code I'm using is as follows:

1      OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
42     ;
43     PROC IMPORT OUT= WORK.FUTURES REPLACE
44                 DATAFILE= "/folders/myfolders/Sugar Beet Steers.xlsx"
45                 DBMS=XLS REPLACE;

NOTE: The previous statement has been deleted.

NOTE: The previous statement has been deleted.

NOTE: The previous statement has been deleted.

46          RANGE="Sheet1$";
47          SCANTEXT=YES;
             ________
             180
48          USEDATE=YES;
             _______
             180
49          SCANTIME=YES;
             ________
             180

ERROR 180-322: Statement is not valid or it is used out of proper order.

50     RUN;

Spreadsheet isn't from Excel V5 or later.  Please open it in Excel and Save as V5 or later

Requested Input File Is Invalid

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.04 seconds
   cpu time        0.05 seconds
 
51     ;
52     OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
62    

;

And the log keeps showing me this:

1      OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
42     ;
43     PROC IMPORT OUT= WORK.FUTURES REPLACE
44                 DATAFILE= "/folders/myfolders/Sugar Beet Steers.xlsx"
45                 DBMS=XLS REPLACE;

NOTE: The previous statement has been deleted.

NOTE: The previous statement has been deleted.

NOTE: The previous statement has been deleted.

46          RANGE="Sheet1$";
47          SCANTEXT=YES;
             ________
             180
48          USEDATE=YES;
             _______
             180
49          SCANTIME=YES;
             ________
             180

ERROR 180-322: Statement is not valid or it is used out of proper order.

50     RUN;

Spreadsheet isn't from Excel V5 or later.  Please open it in Excel and Save as V5 or later

Requested Input File Is Invalid

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.04 seconds
   cpu time        0.05 seconds
 
51     quit;
52     ;
53     OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
63     ;
Super User
Posts: 10,516

Re: ERROR 180-322: Statement is not valid or it is used out of proper order.

The key is in this line:

Spreadsheet isn't from Excel V5 or later.  Please open it in Excel and Save as V5 or later

Requested Input File Is Invalid

though possibly a tad misleading XLS and XLSX are different file formats. Your code tells SAS that you want to read the input file as XLS but the name indicates it is later.

Try DBMS=EXCEL.

All the other errors are due to this.

New Contributor
Posts: 3

Re: ERROR 180-322: Statement is not valid or it is used out of proper order.

When I changed to DBMS=EXCEL it takes care of the ERROR 180-322 but the log still says this:

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;

42 ;

43 PROC IMPORT OUT= WORK.FUTURES REPLACE

44 DATAFILE= "D:/folders/myfolders/Sugar Beet Steers.xlsx"

45 DBMS=EXCEL REPLACE;

ERROR: DBMS type EXCEL not valid for import.

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.01 seconds

  

46 RANGE="Sheet1$";

47 SCANTEXT=YES;

48 USEDATE=YES;

49 SCANTIME=YES;

50 RUN;

51 quit;

52 ;

53 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;

63 ;

New Contributor
Posts: 3

Re: ERROR 180-322: Statement is not valid or it is used out of proper order.

If you would like to use 'DBMS=EXCEL' or 'DBMS=EXCELCS', you have to use PC File server.

 

I have the same error as yours. What I did is to comment out those options, and fortunately I still got the data I want. I'll keep searching some solutions on that error.

 

Ask a Question
Discussion stats
  • 3 replies
  • 1800 views
  • 0 likes
  • 3 in conversation