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 (May 2008, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 1 May 2008 15:58:49 -0400
Reply-To:   Sigurd Hermansen <HERMANS1@WESTAT.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Sigurd Hermansen <HERMANS1@WESTAT.COM>
Subject:   Re: Logic help
Comments:   To: "Keintz, H. Mark" <mkeintz@wharton.upenn.edu>
In-Reply-To:   <0F48071CAE88E940892B3883297EE8470905DC61@RITTENHOUSE.wharton.upenn.edu>
Content-Type:   text/plain; charset="windows-1256"

3361 Data test; 3362 var1=8; var2=0; do i=1 to 1E5; output; end; 3363 var2=1; do i=1 to 1E5; output; end; 3364 3365 var1=9; var2=0; do i=1 to 1E5; output; end; 3366 var2=1; do i=1 to 1E5; output; end; 3367 3368 var1=10; var2=0; do i=1 to 1E5; output; end; 3369 var2=1; do i=1 to 1E5; output; end; 3370 Run;

NOTE: The data set WORK.TEST has 600000 observations and 3 variables. NOTE: DATA statement used (Total process time): real time 0.59 seconds cpu time 0.56 seconds

3371 3372 proc sql _method ; 3373 create table maxTest0 as 3374 select max(var1) as maxVar1 3375 from test 3376 where var2=0 3377 ;

NOTE: SQL execution methods chosen are:

sqxcrta sqxsumn sqxsrc( WORK.TEST ) NOTE: Table WORK.MAXTEST0 created, with 1 rows and 1 columns.

3378 quit; NOTE: PROCEDURE SQL used (Total process time): real time 1.18 seconds cpu time 0.29 seconds

-----Original Message----- From: Keintz, H. Mark [mailto:mkeintz@wharton.upenn.edu] Sent: Thursday, May 01, 2008 3:28 PM To: Sigurd Hermansen Subject: RE: Re: Logic help

Sigurd:

To be a complete role model of efficiency, you might want to do this in the DATA TEST step:

Data test; var1=8; var2=0; do i=1 to 1E5; output; end; var2=1; do i=1 to 1E5; output; end;

var1=9; var2=0; do i=1 to 1E5; output; end; var2=1; do i=1 to 1E5; output; end;

var1=10; var2=0; do i=1 to 1E5; output; end; var2=1; do i=1 to 1E5; output; end; Run;

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Sigurd Hermansen Sent: Thursday, May 01, 2008 1:14 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Logic help

Another method that does not appear to require sorting or specialized filtering works no matter where the maximum appears in a dataset: data test; do i=1 to 1E5; var1=8; var2=0; output; end; do i=1 to 1E5; var1=8; var2=1; output; end; do i=1 to 1E5; var1=9; var2=0; output; end; do i=1 to 1E5; var1=9; var2=1; output; end; do i=1 to 1E5; var1=10; var2=0; output; end; do i=1 to 1E5; var1=10; var2=1; output; end; run; proc sql _method ; create table maxTest0 as select max(var1) as maxVar1 from test where var2=0 ; quit;

Relational database methods in particular define solutions that do not depend on physical ordering of data. For this problem a logical solution, as opposed to a procedural one, doesn't suffer much (if any) from performance inefficiencies:

NOTE: SQL execution methods chosen are: sqxcrta sqxsumn sqxsrc( WORK.TEST ) NOTE: Table WORK.MAXTEST0 created, with 1 rows and 1 columns.

3360 quit; NOTE: PROCEDURE SQL used (Total process time): real time 1.28 seconds cpu time 0.34 seconds S

-----Original Message----- From: owner-sas-l@listserv.uga.edu [mailto:owner-sas-l@listserv.uga.edu] On Behalf Of Ya Huang Sent: Wednesday, April 30, 2008 7:24 PM To: SAS-L@LISTSERV.UGA.EDU; Deep Singh Cc: Ya Huang Subject: Re: Logic help

You are very close:

data want; set have (where=(var2=0)) end=last; if last then output; run;

On Wed, 30 Apr 2008 19:15:23 -0400, DP <adsingh78@GMAIL.COM> wrote:

>Hi, > >How to get the maximum event time (MAXEVETM) that should be the last >value of VAR1 where VAR2=0. > >Have: >VAR1 VAR2 >8 0 >8 0 >8 1 >8 0 >8 1 >9 0 >9 0 >9 0 >9 1 >10 0 >11 1 > >Want: > >VAR1 VAR2 MAXEVETM >10 0 10 > >Can it be done without sorting the data? > >I have this but not sure if correct… > >data want; > set have end=last; > if last and CENSOR=0 then output; >run; > >Thanks a lot! > >DP


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