| Date: | Fri, 3 Jul 2009 17:55:38 -0400 |
| Reply-To: | Nathaniel.Wooding@DOM.COM |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Nat Wooding <Nathaniel.Wooding@DOM.COM> |
| Subject: | Re: a very simple question: base |
| In-Reply-To: | <200907031423.n63AksvF009103@malibu.cc.uga.edu> |
| Content-Type: | text/plain; charset="US-ASCII" |
|---|
I second Art's suggestion about using a retain statement.
Another way to write the if statement would be
if _n_ = 1 then base = variable1;
This assumes that you always want to use the first observation as the
divisor.
Nat Wooding
Environmental Specialist III
Dominion, Environmental Biology
4111 Castlewood Rd
Richmond, VA 23234
Phone:804-271-5313, Fax: 804-271-2977
Cel Phone: 804-205-0752
Arthur Tabachneck
<art297@NETSCAPE.
NET> To
Sent by: "SAS(r) SAS-L@LISTSERV.UGA.EDU
Discussion" cc
<SAS-L@LISTSERV.U
GA.EDU> Subject
Re: a very simple question: base
07/03/2009 10:23
AM
Please respond to
Arthur Tabachneck
<art297@NETSCAPE.
NET>
If the problem is as simple as you describe, you may be able to solve it
with something like:
data have;
input year variable1;
cards;
2007 10
2009 5
2009 3
;
data want (drop=base);
set have;
retain base;
if year eq 2007 then do;
base=variable1;
end;
ratio=variable1/base;
run;
HTH,
Art
---------
On Fri, 3 Jul 2009 00:57:32 -0700, skyline <lautko@GMAIL.COM> wrote:
>Hello,
>A very simple question:
>
>suppose I have a dataset test such as
>
>year month variable1
>2008 1 10
>2008 2 5
>2009 1 5
>2009 2 3
>
>then I run
>
>proce means data=test2;
>var variable1;
>by year;
>output out=test2 mean=variable2;
>run;
>to get (roughly)
>
>year variable2
>2008 7.5
>2009 4
>
>from the previous post, I now know how to get
>
>year variable1
>2007 10
>2009 5
>2009 3
>
>now I would like to get to use the 2007 value as a base so that
>
>year variable1 ratio
>2007 10 1
>2008 5 0.5
>2009 3 0.3
>
>Please advise.
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.
|