Date: Sat, 14 Nov 2009 00:42:04 +0000
Reply-To: toby dunn <tobydunn@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: toby dunn <tobydunn@HOTMAIL.COM>
Subject: Re: Do Loops
In-Reply-To: <fe0c2f6a-b1e5-4de7-b09e-a2d1901e122c@h34g2000yqm.googlegroups.com>
Content-Type: text/plain; charset="iso-8859-1"
Nick ,
To answer your first question if I understand it correctly:
Data Have ;
Input ID TotalMonths ;
Cards ;
1 1
2 2
3 3
4 4
5 10
6 10
7 2
8 12
;
Run ;
Data Need ;
Set Have ;
Retain Flag 1 ;
Do Month = 1 To TotalMonths ;
Output ;
End ;
Run ;
Proc Summary
Data = Need NWay ;
Class Month ;
Output Out = CountsByMonth ( Drop = _Type_ _Freq_ )
Sum( Flag ) = Count ;
Run ;
Proc Print
Data = CountsByMonth ;
Run ;
Now I added ID variable for my benefit as well as the examples.
IF you need quarter as a possible variable and only want to count that person once in a quarter or multiple times in a quarter all can be accomplished in the do loop by controling when an observation is output'ed. It merely takes a little more work but not much. Then simply use the new variables in the Class statement of the Proc Summary.
Toby Dunn
"Don't bail. The best gold is at the bottom of barrels of crap."
Randy Pausch
"Be prepared. Luck is where preparation meets opportunity."
Randy Pausch
> Date: Fri, 13 Nov 2009 07:01:55 -0800
> From: nickcorbin0000@GOOGLEMAIL.COM
> Subject: Re: Do Loops
> To: SAS-L@LISTSERV.UGA.EDU
>
> thanks for all the responses on this.
>
> mark, i've been looking at your solution and it seems to give me what
> i want most efficiently. however, if i want to stratify 'quarter' by 2
> extra variables - say 'channel' and 'type' - how would i do this?
>
> [nick]
_________________________________________________________________
Windows 7: Unclutter your desktop.
http://go.microsoft.com/?linkid=9690331&ocid=PID24727::T:WLMTAGL:ON:WL:en-US:WWL_WIN_evergreen:112009