| Date: | Fri, 29 Jan 2010 14:41:32 -0500 |
| Reply-To: | saslearn chicago <sasswamy@GMAIL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | saslearn chicago <sasswamy@GMAIL.COM> |
| Subject: | Re: Simple Sequence in SAS |
|
| In-Reply-To: | <16FD64291482A34F995D2AF14A5C932C0858BB5B@MAIL002.prod.ds.russell.com> |
| Content-Type: | text/plain; charset=ISO-8859-1 |
|---|
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
>
|