BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
BillB007
Obsidian | Level 7

I am importing a lot of Excel files and creating reports using Proc Tabulate.   Many work but some don't.   The errors I get on some of them are similar to this sample:  

 

"ERROR: Data set WORK.REPORT2NEWSORTEDLONG is not sorted in ascending sequence. The current BY group has Assessment Instrument  Name = ARED BS CAPS ST Final Candidate and the next BY group has Assessment Instrument Name = ARED BS CAPS ST Final CT."

 

I think I know why these are considered out of order, because SAS sorts capital letters before lower case ones, but I sorted these using Proc Sort ahead of time.    I also use the option  /ORDER=DATA  in the class statement of Proc Tabulate and I thought that would make the sort order irrelevant.

 

Any ideas why I'm having this problem and more importantly, how to solve it?

relevant SAS code below.  This is all inside of a macro.  The dataset has been re-organized using proc transpose prior to this.

 

proc tabulate data =&input f=4.0 S=[just=c cellwidth=25]; 
var Col1;
class criterion instrument /ORDER=DATA ;
class _name_ ;
table instrument*criterion all={label='Total' s=[just=R background=goldenrod]}*{s=[background=goldenrod]} ,(_name_='Level' ALL)*Col1=" "*(sum="N"*(f=3.0) ROWPCTSUM="%"*f=mypct. ) /box=&reportdate;
BY instrument; 
run;

 

I've tried this on SAS 9.2 and also with SAS 9.4 with the same results.

 

Thanks!

 

Bill

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Please show the sort, the tabulate and then the errors. If you've sorted you shouldn't see the errors, regardless of the case.

 

Order=Data controls the display of the rows, but the BY statement is where you're having issues. BY does require a sort. 

 

If you're confident your data is in a sort order that works for you and is actually sorted in some manner, you can use the NOTSORTED option on your BY statement. Then it treats the data as BY groups but doesn't check for order, but groupings. 

 

BY instrument notsorted;

View solution in original post

2 REPLIES 2
Reeza
Super User

Please show the sort, the tabulate and then the errors. If you've sorted you shouldn't see the errors, regardless of the case.

 

Order=Data controls the display of the rows, but the BY statement is where you're having issues. BY does require a sort. 

 

If you're confident your data is in a sort order that works for you and is actually sorted in some manner, you can use the NOTSORTED option on your BY statement. Then it treats the data as BY groups but doesn't check for order, but groupings. 

 

BY instrument notsorted;
BillB007
Obsidian | Level 7

Thanks, that solved the problem.  I whacked myself in the head for not seeing that too!  

 

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 2 replies
  • 1146 views
  • 1 like
  • 2 in conversation