Prev: Business Development Manager / Centre Head with ASSYST @ Kolkata.
Next: SAS: decimal place issues
From: bigD on 3 Jun 2010 12:15 On Jun 3, 11:59 am, Arthur Tabachneck <art...(a)netscape.net> wrote: > Are you trying to do something like:? > > data b_until; > set b; > if 13<=length <=500 then do; > n+1; > if n < 87 then delete; > end; > run; > > Art > ------------- > On Jun 3, 11:39 am, bigD <diaphanos...(a)gmail.com> wrote: > > > Locks up the data step. > > > On Jun 3, 11:25 am, Ya <huang8...(a)gmail.com> wrote: > > > > Can you try this? > > > > data b_until; > > > set b; > > > n=0; > > > do until (n=87); > > > if 13<=length <=500 then do; > > > n=n+1; > > > delete; > > > end; > > > end; > > > run; > > > > On Jun 3, 7:08 am, bigD <diaphanos...(a)gmail.com> wrote: > > > > > Hi All, > > > > > I have what I thought was an easy problem, but clearly I don't > > > > understand the do until loop. > > > > I need to delete _only_ 87 records from a data set if they satisfy a > > > > certain condition (length between 13 and 500). > > > > I tried the code below , but it the code is deleting all the records. > > > > > data b_until; > > > > set b; > > > > n=0; > > > > do until (n=87); > > > > if 13<=length <=500 then delete; > > > > n=n+1; > > > > end; > > > > run; > > > > > Then I tried the code below, and it locks up SAS. > > > > > data b_until; > > > > set b; > > > > n=0; > > > > do until (n=87); > > > > if 13<= alc_los <=500 then true=1; > > > > if true=1 then do; > > > > delete; > > > > n+1; > > > > end; > > > > end; > > > > run; > > > > > Thanks for your help. > > > > > BigD.- Hide quoted text - > > > - Show quoted text - That's the ticket! Thanks.
From: Lou on 3 Jun 2010 19:57 "bigD" <diaphanosoma(a)gmail.com> wrote in message news:4c79ae8d-a2f7-4ff8-8af5-59111eedceb0(a)o4g2000vbo.googlegroups.com... > Hi All, > > I have what I thought was an easy problem, but clearly I don't > understand the do until loop. > I need to delete _only_ 87 records from a data set if they satisfy a > certain condition (length between 13 and 500). > I tried the code below , but it the code is deleting all the records. > > data b_until; > set b; > n=0; > do until (n=87); > if 13<=length <=500 then delete; > n=n+1; > end; > run; > > Then I tried the code below, and it locks up SAS. > > data b_until; > set b; > n=0; > do until (n=87); > if 13<= alc_los <=500 then true=1; > if true=1 then do; > delete; > n+1; > end; > end; > run; > > Thanks for your help. > What the DELETE statements does is 1. Not write the current observation to the output dataset 2. Immediately return to the top of the DATA step and process the next iteration. In other words, no statements appearing after the DELETE get executed if the DELETE gets executed. In particular, your N+1 does not happen if the observation meets the delete criterion.
First
|
Prev
|
Pages: 1 2 Prev: Business Development Manager / Centre Head with ASSYST @ Kolkata. Next: SAS: decimal place issues |