[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sas-l
Subject:    Re: Simple Sequence in SAS
From:       Sadia Ali <alisadia786 () GMAIL ! COM>
Date:       2010-01-29 19:57:30
Message-ID: 527cda961001291157r26be6320vcd11a06b71c5f29c () mail ! gmail ! com
[Download RAW message or body]

Hi,

You can start with a zero on obs=1 by :

* method #3 ;
data result3;
   set sample;
   retain D 0;
*if _n_=1 then d=0
   else D+1;*
run;

On Fri, Jan 29, 2010 at 1:41 PM, saslearn chicago <sasswamy@gmail.com>wrote:

> Thanks Mark,
>
> Method 3 works , Is there a way to start from value 0.
> I mean first observation with 0 , then 1 , 2 .... n
> based on my requirement , some of data will contain 0 weeks , so this would
> help to have a sequence with 0
>
> Please let me know
>
> - swamy
> On Fri, Jan 29, 2010 at 2:23 PM, Terjeson, Mark <Mterjeson@russell.com
> >wrote:
>
> > Hi Swamy,
> >
> > Here are a couple of ways:
> >
> >
> > data sample;
> >    input week freq total;
> > cards;
> > 20 3 3
> > 21 4 7
> > 25 2 9
> > ;
> > run;
> >
> >
> >    * method #1 ;
> > data result1;
> >    set sample;
> >    D = _N_;
> > run;
> >
> >
> >    * method #2 ;
> > data result2;
> >    set sample;
> >    retain D 0;
> >    D+1;
> > run;
> >
> >
> >    * method #3 ;
> > data result3;
> >    set sample;
> >    retain D 0;
> >    D=D+1;
> > run;
> >
> >
> >
> > Hope this is helpful.
> >
> >
> > Mark Terjeson
> > Investment Business Intelligence
> > Investment Management & Research
> > Russell Investments
> > 253-439-2367
> >
> >
> > Russell
> > Global Leaders in Multi-Manager Investing
> >
> >
> >
> >
> >
> > -----Original Message-----
> > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
> > saslearn chicago
> > Sent: Friday, January 29, 2010 11:15 AM
> > To: SAS-L@LISTSERV.UGA.EDU
> > Subject: Simple Sequence in SAS
> >
> > All,
> >
> > Can someone tell me the easiest way to Increment a variable in SAS
> > say I have 3 field , week , freq . total in a table
> >
> > week freq  total          D
> > 20      3      3             1
> > 21      4      7             2
> > 25      2      9
> > 3..
> >
> > I wanted a new field 'D' with starting value 1 , goes on till the last
> > row
> > increment by 1
> >
> > Thanks,
> > - swamy
> >
>
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic