Date: Thu, 18 Sep 2008 14:19:58 -0400
Reply-To: Nathaniel.Wooding@DOM.COM
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Nat Wooding <Nathaniel.Wooding@DOM.COM>
Subject: Fw: sum variables for each day -- CORRECTION
Content-Type: text/plain; charset="US-ASCII"
Jen et al.
When I posted a solution using Proc Transpose earlier, I noted that the
zero was not being included in the new sumday name. It appears that I
omitted the necessary ID statement in the Transpose code. The following
code should
work better.
NHW
Data Jen1;
input id drg1_day01 drg2_day01 drg3_day01 drg4_day01 drg1_day02 drg2_day02
drg3_day02 drg4_day02;
cards;
101 1 2 3 4 88 99 77 22
201 33 22 11 44 9 8 7 6
run;
proc transpose out = jen2;
var drg: ;
by id;
run;
Data jen2;
set jen2;
Day = substr( _name_ , 9 ) ;
format day $3.;
run;
proc print;
run;
Proc Sort;
by id day;
* in case they are not sorted already;
run;
Proc Summary;
output out = Jen2 sum = SumDrg;
var col1;
by id day;
run;
Proc Transpose out = Jen2 Prefix = SumDrg_Day ;
var sumdrg;
by id;
ID DAY ;*** THIS WAS LACKING IN MY ORIGINAL POSTING
run;
Proc print;run;
Nat Wooding
Environmental Specialist III
Dominion, Environmental Biology
4111 Castlewood Rd
Richmond, VA 23234
Phone:804-271-5313, Fax: 804-271-2977
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.