Date: Wed, 6 Jul 2005 09:28:51 -0700
Reply-To: "Terjeson, Mark (IM&R)" <Mterjeson@RUSSELL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Terjeson, Mark (IM&R)" <Mterjeson@RUSSELL.COM>
Subject: Re: creating variable of counts of obs for by groups
Content-Type: text/plain; charset="US-ASCII"
Probably for most cases people "think"
of months "within" a year. For example
if you sorted a full sas date you would
be the normal forward chronological order.
When not using a full date with something
like year and month if we put the YYYY first
and then MM for month then chronological is
preserved whether we have an integer variable
or a character variable.
For example when using a date in a filename
for date-stamping purposes having all the
units of measure of date and time in
descending order automatically makes them
show up in your directory in chronological
order. e.g. YYYYMMDDhhmmss, etc.
Another issue (or assumption on my part)
is that monthly meant "each month" would
get delimited for the subtotaling. i.e.
2005 jan would get its own subtotal
2005 feb would get its own subtotal
2005 mar ...
or in sumeric terms
200501 would get its own subtotal
200502 would get its own subtotal
200503 ...
To subtotal by each month you would
want to sort BY YEAR MONTH.
If you sorted BY MONTH YEAR, *and* if
you used first.month, last.month, etc.,
you must remember that the first. last.
flagging toggles whenever the value in
that field changes. Thus you would be
subtotalling all of the Januarys across
all of the years. e.g.
01 2002
01 2003
01 2004
01 2005
last.month substotal(with all 4 years)
02 2002
02 2003
etc.
Because last.month flags toggle at the
end of each unique value, in this case 01
changing to 02.
Of course, you could have this if it is
indeed what you wanted!
Sorting BY YEAR MONTH will give you the
discrete months if last.month gets used.
If using the BY statement with a SET statement
it is handy use PUT _ALL_; if you want to
then look at the log and see what all the first.
and last. flags are doing.
Hope this is helpful.
Mark Terjeson
Senior Programmer Analyst, IM&R
Russell Investment Group
Russell
Global Leaders in Multi-Manager Investing
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
nevin.krishna@GMAIL.COM
Sent: Wednesday, July 06, 2005 9:06 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: creating variable of counts of obs for by groups
Thanks for your solutions!! they work very well..one thing i wanted to
clarify however, you state
"If you sort in descending unit size
(i.e. year then month) you can much
easier use the first. last. stuff
to process all of your steps in just
one datastep."
what do you mean by "unit size" in this case. i see in your example that
you reversed the sort from month year to year month, but i dont follow
the logic..could you please explain? thanks again for your
help..:-)