```Date: Fri, 15 Aug 2008 09:19:34 -0400 Reply-To: Nathaniel.Wooding@DOM.COM Sender: "SAS(r) Discussion" From: Nat Wooding Subject: Re: If else statement question Comments: To: sudip chatterjee In-Reply-To: <1ca751e30808141237w76e957eep70c8dfda1f22f205@mail.gmail.com> Content-Type: text/plain; charset="US-ASCII" Sudip I took your "twice as" and it's counterparts to mean that any estimate greater than twice its predecessor ( or less than half, etc) to mean that the rate was missing. Try the following code and see if it does what you need. Also, do you want to do a 1/3 or times 3 case for the last instance of a subject as well as for the very last obs. The following code appears to be close to what you want but I have not been able to progromatically look ahead to the next obs for cases of the first instance of a subject other than the very first subject. Someone else may have some ideas on this. Data Sudip; input Subject time Rate ; lastrate = lag(rate); cards; 1 1950 11 1 1951 16 1 1952 25 1 1953 300 1 1954 200 1 1955 210 1 1956 1000 1 1957 2000 1 1958 1900 1 1959 1100 2 1950 1011 2 1951 1016 2 1952 1025 2 1953 1300 2 1954 1200 2 1955 1210 2 1956 1000 2 1957 2000 2 1958 1200 2 1959 1100 run; Data Test; set sudip ; by Subject; if _n_ = 1 then do;** first obs; set sudip (firstobs=2 obs=2 keep = rate rename = (rate = nextrate )); ratio = nextrate/rate; if .34 le ratio lt 3 then newrate = rate; else newrate = .; return; end; ** the following loop is not working properly since I cannot think of a way to pass a live ** value to the firstobs and obs in a set statement like I used in the last loop.; if first.subject then do; Where = _n_ + 1 ; set sudip ( keep = rate rename = (rate = nextrate )); * set sudip ( where = ( count = nextobs) keep = rate rename = (rate = nextrate )); ratio = nextrate/rate; if .34 le ratio lt 3 then newrate = rate; else newrate = .; return; end; ratio = rate / lastrate; if last.subject then do;** last obs for a group ; if .33 lt ratio lt 3 then newrate = rate; else newrate = .; return; end; if .50 lt ratio lt 2 then newrate = rate; else newrate = .; * drop nextrate; 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 sudip chatterjee To Sent by: "SAS(r) SAS-L@LISTSERV.UGA.EDU Discussion" cc Subject If else statement question 08/14/2008 03:37 PM Please respond to sudip chatterjee Dear User's I have 100 subjects where rate of certain disease was estimated in 10 years time points Say like this Subject time Rate 1 1950 11 1 1951 16 1 1952 25 1 1953 300 1 1954 200 1 1955 210 1 1956 1000 1 1957 2000 1 1958 1900 1 1959 1100 2 1950 1011 2 1951 1016 2 1952 1025 2 1953 1300 2 1954 1200 2 1955 1210 2 1956 1000 2 1957 2000 2 1958 1200 2 1959 1100 Now what I want is to check every rate estimation each year and if say an estimate is twice as big or small as previous year then I put that as . Now for the first and last data I will check if that rate is as 3 times high or smaller than its immediate neighbour if yes I will put that as . I need some idea to code this Thanks 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