LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (August 2009, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 19 Aug 2009 08:27:53 -0500
Reply-To:     "Data _null_;" <iebupdte@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Data _null_;" <iebupdte@GMAIL.COM>
Subject:      Re: The SUM statement (was: Deleting columns)
Comments: To: "Keintz, H. Mark" <mkeintz@wharton.upenn.edu>
In-Reply-To:  <FEE685C811A7E44AAD17E47B2A966E29A858674CA1@KITE.wharton.upenn.edu>
Content-Type: text/plain; charset=ISO-8859-1

I don't get that result. I get the expected(documented) result with no message. Version 9.1.3.

1255 data _null_; 1256 put x=; 1257 x + (2*x); 1258 run;

x=0

On 8/19/09, Keintz, H. Mark <mkeintz@wharton.upenn.edu> wrote: > Art et. al.: > > There IS documentation. The page http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000289454.htm (titled "SUM statement") literally says that > > x+(expression); > > is equivalent to > > retain variable 0; > variable=sum(variable,expression); > > > But that is not always true, as is shown by the sas note produced by: > > data _null_; > x+(2*x); > run; > > NOTE: Missing values were generated as a result of performing an operation on missing values. > Each place is given by: (Number of times) at (Line):(Column). > > > The sum statement appears to actually be equivalent to: > > retain variable .; /** NOT ZERO **/ > variable=sum(variable,expression); > > Of course, the above is effectively the same as "retain variable 0" as long as "expression" does not involve the summing variable. > > Regards, > Mark > > > > > -----Original Message----- > > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of > > Arthur Tabachneck > > Sent: Sunday, August 16, 2009 9:24 AM > > To: SAS-L@LISTSERV.UGA.EDU > > Subject: Re: Deleting columns > > > > Nat, > > > > While Palapara was correct, I'm not sure that I've ever read that using > > the > > x+1 rather than =x+1 syntax both retains the variable AND initializes > > it to > > zero. Of course, from the example it obviously does, but I didn't know > > that. > > > > Of course, as shown below, using the =x+1 requires x to be initialized > > in > > order to achieve the desired results. > > > > DATA one; > > input X; > > retain Y ; > > if mod( x, 3 ) = 1 then y=y + 1; > > cards; > > 1 > > 2 > > 3 > > 4 > > 5 > > 6 > > 7 > > 8 > > 9 > > ; > > proc print data = one ; > > run; > > > > DATA one; > > input X; > > retain Y 0 ; > > if mod( x, 3 ) = 1 then y=y + 1; > > cards; > > 1 > > 2 > > 3 > > 4 > > 5 > > 6 > > 7 > > 8 > > 9 > > ; > > proc print data = one ; > > run; > > > > Art > > --------- > > On Sun, 16 Aug 2009 09:02:01 -0400, Nathaniel Wooding > > <nathaniel.wooding@DOM.COM> wrote: > > > > >Palapara > > > > > >You are quite right. When I wrote this, I was thinking that I needed > > to > > initialize Y to 0 but the code > > > > > >Data ; > > >Retain y 0; > > >X+1; > > >Y+1; > > >Run; > > > > > >disproves this. I used Retain since that is a simple way to initialize > > a > > value when one actually needs to initialize it. > > > > > >Nat Wooding > > > > > >-----Original Message----- > > >From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of > > palapara > > >Sent: Friday, August 14, 2009 7:07 PM > > >To: SAS-L@LISTSERV.UGA.EDU > > >Subject: Re: Deleting columns > > > > > >I think "retain Y 0 ;" this command could be omitted, since y+1 means > > >y is retained automatically. > > > > > > > > >On Aug 14, 2:10 pm, nathaniel.wood...@DOM.COM (Nathaniel Wooding) > > >wrote: > > >> I looked a second time at your post. A simpler approach is > > >> > > >> DATA one; > > >> input X; > > >> > > >> retain Y 0 ; > > >> if mod( x, 3 ) = 1 then y + 1; > > >> cards; > > >> 1 > > >> 2 > > >> 3 > > >> 4 > > >> 5 > > >> 6 > > >> 7 > > >> 8 > > >> 9 > > >> run; > > >> proc print data = one ; > > >> run; > > >> > > >> -----Original Message----- > > >> From: SAS(r) Discussion [mailto:SA...@LISTSERV.UGA.EDU] On Behalf Of > > Nickname unavailable > > >> Sent: Friday, August 14, 2009 1:35 PM > > >> To: SA...@LISTSERV.UGA.EDU > > >> Subject: Re: Deleting columns > > >> > > >> I have a variable that is a simple count variable. like this. > > >> > > >> X > > >> 1 > > >> 2 > > >> 3 > > >> 4 > > >> 5 > > >> 6 > > >> 7 > > >> 8 > > >> 9 > > >> > > >> I would like to create another variable Y that looks something like > > >> this. Every 3 observations has a single value starting from the > > value > > >> of 1. > > >> > > >> X Y > > >> 1 1 > > >> 2 1 > > >> 3 1 > > >> 4 2 > > >> 5 2 > > >> 6 2 > > >> 7 3 > > >> 8 3 > > >> 9 3 > > >> > > >> and so on. Anyone has an idea? Would greatly appreciate it. > > >> 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. > > >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