BookmarkSubscribeRSS Feed
kegong
Calcite | Level 5

Dear experts,

 

I received this error 180-322 message while I was trying to run below:

 

PROC IMPORT OUT= WORK.FISCAL
DATAFILE= "D:\Summer 2019 Work\Summer19\Ke Summer Data"
DBMS= XLS;
RANGE="Sheet1$";
GETNAMES=YES;
MIXED=NO;
SCANTEXT=YES;
USEDATE=YES;
SCANTIME=YES;
RUN;

 

And this is the detailed error message:

 

1 PROC IMPORT OUT= WORK.FISCAL
2 DATAFILE= "D:\Summer 2019 Work\Summer19\Ke Summer Data"
3 DBMS= XLS;
NOTE: The previous statement has been deleted.
NOTE: The previous statement has been deleted.
4 RANGE="Sheet1$";
NOTE: The previous statement has been deleted.
5 GETNAMES=YES;
6 MIXED=NO;
7 SCANTEXT=YES;
--------
180
8 USEDATE=YES;
-------
180
9 SCANTIME=YES;
--------
180
ERROR 180-322: Statement is not valid or it is used out of proper order.

 

I'm not sure what happened. Could someone please help me out? Thanks very much!

 

10 REPLIES 10
stechafle
Calcite | Level 5

Maybe try DBMS=EXCEL instead? I couldn't find any documentation on DBMS=XLS that had all of the options you listed. See https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=acpcref&docsetTarget=n... for more documentation.

kegong
Calcite | Level 5
@stechafle Thanks a lot for your reply! Below is what I originally used:

PROC IMPORT OUT= WORK.FISCAL
DATAFILE= "D:\Summer 2019 Work\Summer19\Ke Summer Data"
DBMS=EXCEL REPLACE;

But then I got another error message for running this.

ERROR: Connect: Class not registered
ERROR: Error in the LIBNAME statement.
ERROR: Connection Failed. See log for details

Seems like this error happens when importing 32-bit excel file to a 64-bit SAS.But my Office 365 is already 64-bit. So I'm totaly confused...
ballardw
Super User

How about showing the actual entire name of the data file???

 

DATAFILE= "D:\Summer 2019 Work\Summer19\Ke Summer Data" is sort of incomplete from many purposes.

 

 

You may also have to check to see if someone "lied" to Excel. You will find people that create files as HTML, XML or even CSV but name the file with XLS or extension so Excel will be the default program to open the file. Any of those will likely fail to import.

 

 

Or try doing a FILE SAVE AS from Excel to a CSV format and import that.

kegong
Calcite | Level 5

@ballardw Thank you very much but my problem remains... I double checked the file, the data file property shows that it's an xls file. I even tried convert it into a csv and an xml file. Neither one works when I tried to import them into SAS...

ChrisNZ
Tourmaline | Level 20

Why don't you specify the proper file name?

 

DATAFILE= "D:\Summer 2019 Work\Summer19\Ke Summer Data.xls"

kegong
Calcite | Level 5

@ChrisNZ Thanks a lot for your help. I added xls to the file name but the problem remains. But it worked when I saved the xls file as a csv file and deleted below rows:

 

RANGE="Sheet1$";

MIXED=NO;
SCANTEXT=YES;
USEDATE=YES;
SCANTIME=YES;

 

So now I'm using this and it works out well:

 

PROC IMPORT OUT= WORK.FISCAL
DATAFILE= "D:\OD - Copy\Research Projects\Dr. Johnson\CEO effect\Summer 2019 Work\Summer19\Ke_Summer_Data.csv"
DBMS=CSV REPLACE; GETNAMES=YES;
RUN;

 

But I'm not sure whether deleting the setting of date format etc damaged the dataset...

ChrisNZ
Tourmaline | Level 20

Can't comment further without seeing more code, but the messages you were seeing relate to invalid/incompatible values for the different options chosen (DBMS=   SCANTEXT=   USEDATE=    SCANTIME=  etc). Not all engines use all options.

kegong
Calcite | Level 5

@ChrisNZ Thanks again for clarifying. I think the data imported to SAS is good. So I'll go with the reduced code. Have a nice weekend!

ballardw
Super User

@kegong wrote:

@ChrisNZ Thanks a lot for your help. I added xls to the file name but the problem remains. But it worked when I saved the xls file as a csv file and deleted below rows:

 

RANGE="Sheet1$";

MIXED=NO;
SCANTEXT=YES;
USEDATE=YES;
SCANTIME=YES;

 

So now I'm using this and it works out well:

 

PROC IMPORT OUT= WORK.FISCAL
DATAFILE= "D:\OD - Copy\Research Projects\Dr. Johnson\CEO effect\Summer 2019 Work\Summer19\Ke_Summer_Data.csv"
DBMS=CSV REPLACE; GETNAMES=YES;
RUN;

 

But I'm not sure whether deleting the setting of date format etc damaged the dataset...


I suggest also using GUESSINGROWS=MAX; This option, not available for XLS, XLSX and many database formats, works with delimited text such as CSV to examine the entire dataset before guessing as the variable type and length. SCANTEXT is somewhat similar in purpose.

 

But do look at the data step code generated to ensure the variables are read as needed.

kegong
Calcite | Level 5

@ballardw Thank you so much. It works pretty well. 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 10 replies
  • 6989 views
  • 0 likes
  • 4 in conversation