SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Phil_NZ
Barite | Level 11

Hi all, 

 

Today, I put the GUESSINGROW=MAX to my code and it announce an error even I checked with some documents

My code is:

1         + proc import datafile= "C:\Users\pnguyen\OneDrive - Massey University\PhD JOURNEY\leniency & 
operating\dataxlsx\ARGENTINAARS"       out= ARGENTINA_sheet1      dbms= xlsx       replace;
NOTE: The previous statement has been deleted.
NOTE: Line generated by the CALL EXECUTE routine.
1         +
      guessingrows=max;      range= "Sheet1$A:X";      getnames= yes;

____________                                                                                                                        

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

The problem here is the code GUESSINGROW=MAX

I check with this document and I think I put the statement above in the correct order already, I am wondering if I did anything wrong.

 

Thank you and warm regards.

 

Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.
1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

No, I don't have something in writing at hand. I've just done a test where I've created and Excel with 1M rows where I've had only in the cell in row 1M a character (and in all the cells before digits only). Then I've run Proc Import and the resulting variable was of type character. Without this character in the millionth cell the result was a numerical variable.

View solution in original post

10 REPLIES 10
SASKiwi
PROC Star

GUESSINGROWS is not a valid option for Excel spreadsheets. If you want to use it convert your spreadsheet to a CSV where it is a valid option.

Phil_NZ
Barite | Level 11

So, can I ask, how many rows proc import with excel try to guess for the attributes of one variables? Is it 20 rows as default?

 

Thank you.

Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.
Patrick
Opal | Level 21

With XLSX SAS inspects all rows so result as if you would (could) set guessingrow=max.

I've done in the past a test with a .xlsx where I've had a column with all numeric values and only on the millionth row a character value. The import resulted in a character variable.

Phil_NZ
Barite | Level 11

Hi @Patrick 

 

Interesting, do you have any document about this statement? I am curious about that. The last time I saw a sentence "SAS will try its best to guess the attribute of a variables" but not say something explicitly as yours.

 

Best regards.

With XLSX SAS inspects all rows so result as if you would (could) set guessingrow=max

 

Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.
Patrick
Opal | Level 21

No, I don't have something in writing at hand. I've just done a test where I've created and Excel with 1M rows where I've had only in the cell in row 1M a character (and in all the cells before digits only). Then I've run Proc Import and the resulting variable was of type character. Without this character in the millionth cell the result was a numerical variable.

SASKiwi
PROC Star

My understanding is that there is a default if you use the SAS EXCEL engine and it is set in the Windows Registry where TypeGuessRows to 8 rows:

 

screenshot38.JPG

Phil_NZ
Barite | Level 11
Hi @SASKiwi
Thank you for your reply!
So, you means GUESSINGROW =8 in your case?. Can we adjust this value?. And if it the case, why @Patrick has his result as mentioned.

Warmest regards.
Phil.
Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.
SASKiwi
PROC Star

@Phil_NZ  - I'm referring to the SAS EXCEL engine and @Patrick is referring to the SAS XLSX engine. The SAS EXCEL engine uses the Microsoft JET engine which is governed by the Windows Registry setting. Yes you can modify it - a value of 0 will maximise the number of guessing rows. However if you corrupt the Windows Registry then your PC may refuse to run so change at your own risk!

 

This excellent paper explains more details: https://support.sas.com/resources/papers/proceedings/proceedings/sugi31/020-31.pdf

 

The DBSASTYPE option mentioned in the paper may be worth exploring.

 

Patrick
Opal | Level 21

@Phil_NZ The code in your initial post shows that you're using the XLSX engine where changing the value in the registry doesn't apply. 

This change in the registry would apply for the default used with the EXCEL engine if you don't explicitly define guessingrow=

A_Kh
Barite | Level 11

I thing the error here is in PROC IMPORT statement. DATAFILE option doesn't refer to xlsx file. 

Try this:

PROC IMPORT DATAFILE= "C:\USERS\....\ARGENTINAARS.xlsx"

proc import datafile= "C:\Users\pnguyen\OneDrive - Massey University\PhD JOURNEY\leniency & 
operating\dataxlsx\ARGENTINAARS"       out= ARGENTINA_sheet1      dbms= xlsx       replace;

 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 6447 views
  • 4 likes
  • 4 in conversation