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 (June 2002, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 24 Jun 2002 11:04:43 +0200
Reply-To:     Jarosław Parzych <spljap@SPL.SAS.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jarosław Parzych <spljap@SPL.SAS.COM>
Organization: SAS Institute, Inc.
Subject:      Re: More about repeated counting

Hi,

To get column totals, at the end of previous code, you can add this:

proc means data=report NOPRINT; class id; var _1 _2 _3 _4 total; output out=report2 (DROP=_TYPE_ _FREQ_)SUM=; run;

For the second table (there shold be 0 new comers in MARCH) try this:

data comers (drop=lmonth); retain month 1; set test2 (drop = _FREQ_); by id; lmonth= lag(month);

if first.id and month eq 1 then comers =0; else if first.id and month ne 1 then comers =1; else if lmonth eq month-1 then comers=0; else if lmonth ne month-1 then comers=1; run;

proc sort data=test2 (drop=_FREQ_) out=leavers; by ID descending month; run;

data leavers2 (drop=lmonth); retain month 1; set leavers; by id; lmonth= lag(month);

if first.id and month eq 4 then leavers =0; else if first.id and month ne 4 then leavers =1; else if lmonth eq month+1 then leavers=0; else if lmonth ne month+1 then leavers=1; run;

proc sort data=leavers2; by id month; run;

data cmlv; set comers; set leavers2; run;

proc sort data=cmlv; by month; run;

proc means data=cmlv NOPRINT NWAY; by month; var comers leavers; output out=cmlv2 (drop=_:)SUM=; run;

Regards, Jarek.

Użytkownik "YCF" <s007422@cuhk.edu.hk> napisał w wiadomości news:af6ee5$1rj0$1@ijustice.itsc.cuhk.edu.hk... > Hi all, > Last time, I had posted a similar question and it was solved. This time I > have the same dataset as previous: > id month > s008133 02 > s008133 03 > s008133 04 > s551744 01 > s551744 02 > s551744 02 > a004122 02 > a004122 04 > > But this time,I want to make a summary table and the expected output is > like this:(It is counting the frequency of existence of each id in each > month) > id JAN FEB MAR APR TOTAL > a004122 0 1 0 1 2 > s008133 0 1 1 1 3 > s551744 1 2 0 0 3 > Total 1 4 1 2 8 > > also, I want to make a summary table like this: > no.of New Comers no.of Leavers > JAN 0 0 > FEB 2 2 > MAR 1 0 > APR 1 0 > > E.g. if a id number exists in FEB but not in JAN, then there is a new comer > in FEB. If a id number in FEB but NOT in MAR, then it counts as there is a > leaver in FEB. I have some idea about this but I don't know how to count the > COLUMNS TOTAL and produce the second table. Thanks for your help!!! > > YCF > >


Back to: Top of message | Previous page | Main SAS-L page