Date: Wed, 23 Jul 2008 17:39:20 -0400
Reply-To: "Howard Schreier <hs AT dc-sug DOT org>"
<schreier.junk.mail@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Howard Schreier <hs AT dc-sug DOT org>"
<schreier.junk.mail@GMAIL.COM>
Subject: Re: Totaling of groups
On Wed, 23 Jul 2008 13:02:28 -0700, Terjeson, Mark <Mterjeson@RUSSELL.COM>
wrote:
>Him
>
>Remembering that all the variable just
>sit in the Program Data Vector(PDV)
>during each datastep iteration, we can
>assume that each OUTPUT statement we
>use will just output what is in the PDV.
>Thus, we can alter one or more variables
>as we desire prior to an OUTPUT call.
>
>
>
>data test;
> input subject group;
>cards;
>1 1
>2 2
>3 2
>4 3
>5 3
>6 1
>7 3
>8 1
>9 1
>;
>run;
>
>
>data test1;
> set test;
>
> group1 = group;
> output;
>
> if group in (2,3) then
> do;
> group1 = 23;
> output;
> end;
>
>run;
>
>
>
>
>Hope this is helpful.
Looks helpful to me, as a solution to the problem as presented.
However, I wonder whether introducing the additional observations ia a good
idea. I usually find that having totals or subtotals rolled into a data set
becomes awkward. Also, I suspect that a multilabel format might be a better
solution. Of course one can't be sure without knowing the whole task.
>
>
>Mark Terjeson
>Senior Programmer Analyst
>Investment Management & Research
>Russell Investments
>
>
>Russell Investments
>Global Leaders in Multi-Manager Investing
>
>
>
>
>
>
>-----Original Message-----
>From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of sas
>biology
>Sent: Wednesday, July 23, 2008 12:48 PM
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: Totaling of groups
>
>Hi group,
>
>I have the following data.
>
>*
>
>data* test;
>
>input subject group;
>
>cards;
>
>1 1
>
>2 2
>
>3 2
>
>4 3
>
>5 3
>
>6 1
>
>7 3
>
>8 1
>
>9 1
>
>;
>
>run;
>
>
>
>I want to create an extra recorn when group in (2 3) so that I can
>derive a
>new group (total of 2 and 3 groups) which will be used later in my
>program.
>*
>
>*
>*
>
>data* test1;
>
>set test;
>
>if group in (*2* *3*) then do;
>
>output;
>
>end;
>
>output;
>*
>
>run*;
>
>*This program works fine but I want to create another variable (group1)
>with
>same values of 'group' for old records but 23 value for newly created
>records. How can i do that?*
>
>*My final data should look as given below*
>
>*subject group group1
>1 1 1
>2 2 2
>2 2 23
>3 2 2
>3 2 23
>4 3 3
>4 3 23
>5 3 3
>5 3 23
>6 1 1
>7 3 3
>7 3 23
>8 1 1
>9 1 1*
>
>*thanks in advance.*
>
>*SB
>*
|