LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (January 2012, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 24 Jan 2012 18:00:28 +0000
Reply-To:   Mike Rhoads <RHOADSM1@WESTAT.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Mike Rhoads <RHOADSM1@WESTAT.COM>
Subject:   Re: Coding practices involving the Excel Libname
Comments:   To: Nat Wooding <nathani@VERIZON.NET>
In-Reply-To:   <75CD294654DC4014A18C4DF6F6C9E2B4@D1871RB1>
Content-Type:   text/plain; charset="us-ascii"

Nat,

Or, rather than being "sloppy" you could set the system option SORTPGM to SAS before running the PROC SORT, and back to BEST afterwards. ;-)

Mike Rhoads RhoadsM1@Westat.com

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Nat Wooding Sent: Tuesday, January 24, 2012 8:27 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Coding practices involving the Excel Libname

Good time of the day to wherever you may be.

A few minutes ago, I was playing with some sample code for a friend and in this code, I was reading the data from a workbook using the Libname engine. My initial code was similar to

Libname getdata 'C:\workbook.xlsx';

Data start;

Set getdata.'sheet1$'n;

Run;

Proc sort data = start ;

By ..

More SAS stuff that included a by statement in a data step.

This did the job nicely but I decided to tighten the code a bit and get rid of the initial data step so it became

Libname getdata 'C:\workbook.xlsx';

Proc sort data = getdata.'sheet1$'n out = start;

By ..

More SAS stuff..

________________________________________________

Now, SAS complains that the data are not sorted properly. A clue about this appears in the log:

NOTE: Sorting was performed by the data source.

NOTE: There were 576 observations read from the data set NO.'rate-variety_RV$'n.

NOTE: The data set WORK.START has 576 observations and 24 variables

So it appears that SAS told Excel to do the sorting and the Excel sort order differs from that used by SAS. And, for once, here is an instance where seemingly sloppy coding is really needed.

Nat Wooding


Back to: Top of message | Previous page | Main SAS-L page