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 (August 2008, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 8 Aug 2008 13:36:14 -0400
Reply-To:   Nathaniel.Wooding@DOM.COM
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Nat Wooding <Nathaniel.Wooding@DOM.COM>
Subject:   Re: missing values
Comments:   To: "dc353@hotmail.com" <dc353@HOTMAIL.COM>
In-Reply-To:   <4d6aaa3b-7c56-4f34-aef1-ce1c590ec408@a70g2000hsh.googlegroups.com>
Content-Type:   text/plain; charset="US-ASCII"

The following seems to do what you asked for.

Data ticker; informat Date 8. Ticker $3. Tna 8.; input date ticker Tna; OriginalTNA = Tna;** just for checking later; cards; 1 abc . 2 abc . 3 abc . 4 abc 5 5 abc 7 6 abc . 7 abc . 1 xyz 3 2 xyz . Proc print; run; Proc sort; by descending ticker descending date ; run;

Data Wanted; set ticker; by descending ticker ; if first.ticker then TNAHOLD = .; RETAIN TNAHOLD; if TNA ne . then TNAHold = TNA ; if last.ticker and TNA = . Then TNA = TNAHOLD; run; Proc Print; run;

Proc Sort; by ticker date; run; Proc print; run;

Nat Wooding Environmental Specialist III Dominion, Environmental Biology 4111 Castlewood Rd Richmond, VA 23234 Phone:804-271-5313, Fax: 804-271-2977

"dc353@hotmail.co m" <dc353@HOTMAIL.CO To M> SAS-L@LISTSERV.UGA.EDU Sent by: "SAS(r) cc Discussion" <SAS-L@LISTSERV.U Subject GA.EDU> missing values

08/08/2008 11:05 AM

Please respond to "dc353@hotmail.co m" <dc353@HOTMAIL.CO M>

Hi,

I have a dataset as follows:

DATE TICKER TNA

the dataset is sorted by TICKER DATE

There are no missing observations for either TICKER or DATE

Sometimes the first n observations for TNA are missing. If TNA is missing for the first observation (for any TICKER) I need to replace the missing value with the first non missing value for that TICKER. I'd like to be able to do this with only going through the records that I need to. Appreciate any suggestions.

example:

Date Ticker Tna 1 abc . 2 abc . 3 abc . 4 abc 5 5 abc 7 6 abc . 7 abc . 1 xyz 3 2 xyz .

need to convert to:

Date Ticker Tna 1 abc 5 2 abc . 3 abc . 4 abc 5 5 abc 7 6 abc . 7 abc . 1 xyz 3 2 xyz .

CONFIDENTIALITY NOTICE: This electronic message contains information which may be legally confidential and/or privileged and does not in any case represent a firm ENERGY COMMODITY bid or offer relating thereto which binds the sender without an additional express written confirmation to that effect. The information is intended solely for the individual or entity named above and access by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution, or use of the contents of this information is prohibited and may be unlawful. If you have received this electronic transmission in error, please reply immediately to the sender that you have received the message in error, and delete it. Thank you.


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