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 (September 2006, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 28 Sep 2006 14:03:54 +0000
Reply-To:     toby dunn <tobydunn@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         toby dunn <tobydunn@HOTMAIL.COM>
Subject:      Re: By group Processing
Comments: To: oldscot82@YAHOO.COM
In-Reply-To:  <1159451676.307031.74790@i3g2000cwc.googlegroups.com>
Content-Type: text/plain; format=flowed

Try something like:

Proc SQL ; Create Table Temp As Select * , Max( Payment ) As Keep From Have Group By ID ; Quit ;

Data Pay ( Drop = Keep ) NoPay ( Drop = Keep ) ; Set Temp ;

If Keep Then Output Pay ; Else Output NoPay ;

Run ;

Toby Dunn

When everything is coming at you all at once, your in the wrong lane.

A truly happy person is someone who can smile and enjoy the scenery on a detour.

From: Newbie <oldscot82@YAHOO.COM> Reply-To: Newbie <oldscot82@YAHOO.COM> To: SAS-L@LISTSERV.UGA.EDU Subject: By group Processing Date: Thu, 28 Sep 2006 06:54:36 -0700

I would like to output data to a new dataset based on certain criteria. I am using by group processing as well as LAST. but I am not getting the results I want. A simple version of my data is like this. LINE ID PAYMENT 1 A 25 2 A 0 3 A 0 1 B 0 2 C 50 3 C 0 4 C 0 5 C 0

I would like to extract all lines for an ID as long as the payment is greater than 0. If the payment is 0 or less , I would like to extract it to another data set. If there is a payment , it is always on line 1. However, I want my code to be able to recognize a payment on any line and output as necessary.

My two output data sets would look like this.

LINE ID PAYMENT 1 A 25 2 A 0 3 A 0 1 C 50 2 C 0 3 C 0 4 C 0

LINE ID PAYMENT 1 B 0 2 B 0

Here is my unsuccessful attempt; data a b; set c; by id ; if payment > 0 then output a;else output b; run;

Any suggestion would be appreciated.

Thanks!


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