Date: Tue, 3 Jul 2001 08:56:39 -0400
Reply-To: "Fehd, Ronald J." <rjf2@CDC.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Fehd, Ronald J." <rjf2@CDC.GOV>
Subject: Re: DO - END
Content-Type: text/plain; charset="iso-8859-1"
This is a private reply that I am fetching from my archives.
The single data step posted yesterday
took a bit of reading to figure out what was going on.
reading and rereading the data set to put the Total on each obs
was ... ingenious. and obfuscating.
See use of proc MEANS/SUMMARY at end.
> From: mto [mailto:firstname.lastname@example.org]
> I now understand that I don't need to use TOT=TOT + AMT.
> Will you please explain these statements a little more for me:
> 1. F =_N_;
> 2. L =_N_;
_N_ is the observation number; it is SAS-generated.
> 3. OBSNUM= F TO L;
well, I would have named these Lo and Hi.
hmmmm, F and L, ... ah: First and Last!
> 4. POINT=OBSNUM;
> > 11 DO OBSNUM= F TO L;
> > 12 SET MERGED POINT=OBSNUM; OUTPUT; END;
read the data set from ObsNum = First to Last
for this ID number.
> 5. "You could compute the Tot with proc MEANS and merge the
> MEANS output with MERGED".
others will chime in that you can use proc SUMMARY instead.
proc MEANS data = MERGED;
class Trid;%*may not be needed;
out = SUM %*data set name;
sum = Sum; %*variable name: Tot?;
Ron Fehd the macro maven CDC Atlanta GA USA RJF2@cdc.gov
OpSys: WinNT Ver: 8.1
---> cheerful provider of UNTESTED SAS code!*! <---