| Date: | Wed, 2 Aug 2000 16:12:20 +0200 |
| Reply-To: | Claus Gotfred Rasmussen <CGR@ACCEPTCARD.DK> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Claus Gotfred Rasmussen <CGR@ACCEPTCARD.DK> |
| Subject: | FW: how to get cumulative freq out of a proc freq |
| Content-Type: | text/plain; charset="iso-8859-1" |
|---|
Hi again,
I've just solved this my self - with inspiration from Ronald & Veronica -
thanks.
As I mentioned before, I have several BY variables in my proc freq, and in
the following datastep i have compressed the values of all of these BY
variables into a single variable, which is used to reset cumcount to zero:
proc freq data=data1;
table var1 /out=out;
by var2 var3 var4;
run;
data cum;
retain cumfreq;
length cumreset $60;
set out;
cumreset=trim(var2!!var3!!var4);
if cumreset ne lag(cumreset) then cumfreq=0;
cumfreq+count;
run;
- this does the trick!
Regards,
Claus
-----Original Message-----
From: Claus Gotfred Rasmussen
Sent: Wednesday, August 02, 2000 3:57 PM
To: 'SAS-L@LISTSERV.UGA.EDU'
Subject: RE: how to get cumulative freq out of a proc freq
Hi,
I am sorry that I didn't explain everything in the first post - I have this
problem:
In my proc freq I use several variables in a BY statement, and I want the
cum freq's within these BY groups. My output window looks like this:
*************sas output**************
niche0=ung
The FREQ Procedure
Cumulative Cumulative
score10 Frequency Percent Frequency Percent
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
10 1 0.02 1 0.02
20 5 0.08 6 0.10
30 14 0.23 20 0.33
.
.
.
niche0=gl
The FREQ Procedure
Cumulative Cumulative
score10 Frequency Percent Frequency Percent
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
20 3 0.01 3 0.01
30 12 0.05 15 0.07
40 12 0.05 27 0.12
.
.
.
*******************
produced by this code:
proc freq ;
table score10;
by niche0;
run;
- hope this explains more
-----Original Message-----
From: Fehd, Ronald J. [mailto:rjf2@CDC.GOV]
Sent: Wednesday, August 02, 2000 3:31 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: how to get cumulative freq out of a proc freq
> From: Claus Gotfred Rasmussen [mailto:CGR@ACCEPTCARD.DK]
> When one creates a one way table with proc freq, the
> cumulative frequencies
> are displayed on the screen - can these be included in the
> output data set
> in any way?
You will have to have a data step where you add the cumulative variables.
proc FREQ ...;
tables Var / out = FREQ;
data FREQ;
retain CumCount CumPercent 0;
set FREQ;
CumCount + Count;
CumPercent + Percent;
Ron Fehd the macro maven CDC Atlanta GA USA RJF2@cdc.gov
---> cheerful provider of UNTESTED SAS code!*! <---
|