Date: Tue, 1 Feb 2011 18:29:46 -0500
Reply-To: Arthur Tabachneck <art297@ROGERS.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Arthur Tabachneck <art297@ROGERS.COM>
Subject: Re: How to count via Loop Counting
In-Reply-To: <AANLkTimTiu8PvKmwaUonyDJNv4EZx0ntdmPJwmPAzMAM@mail.gmail.com>
Content-Type: text/plain; charset="us-ascii"
Bill,
Based on what Joe and Toby have said, then I would recommend putting the
calculations in a view, using by statements to summarize on the fly, and
simply building a proc report or series of proc freqs (or whatever) to
access the view and do your desired analyses.
If you did that, you could always also schedule the program to run at
whatever periods you need to provide the information.
Art
_____
From: Joe Matise [mailto:snoopy369@gmail.com]
Sent: Tuesday, February 01, 2011 6:23 PM
To: Arthur Tabachneck
Cc: SAS-L@listserv.uga.edu
Subject: Re: How to count via Loop Counting
Yup - as Toby said, as long as the 'set whatever' has been updated (whether
that be a SQL database or other external data source, or even just a SAS
dataset that is the result of some process), that view will always reference
the up to date data.
-Joe
On Tue, Feb 1, 2011 at 5:11 PM, Arthur Tabachneck <art297@rogers.com> wrote:
Joe,
Almost, but where the view simply gets updated with new data. It's quite
possibly a feature of views I just never realized was there.
For example, say "whatever" in your example is a sqlserver database. Once
today_view is created does it automatically reflect the changes and
additions that are made to "whatever"?
Art
_____
From: Joe Matise [mailto:snoopy369@gmail.com]
Sent: Tuesday, February 01, 2011 5:54 PM
To: Arthur Tabachneck
Cc: SAS-L@listserv.uga.edu
Subject: Re: How to count via Loop Counting
You mean a datastep view?? Or something else?
data today_view/view=today_view;
set whatever;
if dayvar > today() - 7 then week=1; else week=0;
if dayvar > today() - 30 then month=1; else month=0;
if dayvar > today() - 365 then year=1; *obviously intck is better for these
two, just being simplistic;
run;
proc means data=today_view;
class week month year;
var datavar;
run;
That would approximately do what you're describing, if I understand it
correctly. Of course PROC SQL can also do a lot with views.
-Joe
On Tue, Feb 1, 2011 at 4:49 PM, Arthur Tabachneck <art297@rogers.com> wrote:
Bill,
This isn't an answer but, rather, a secondary question for the list.
When I first saw this question I was going to recommend doing it all within
a view so that the calculations would ALWAYS look up the current day.
Is there a way to create a view of a database or at least of a file that can
be updated?
That happens to be an area of SAS that I've never had to work with, but a
fascinating concept.
Just curious,
Art
-------
On Tue, 1 Feb 2011 16:31:43 -0600, Joe Matise <snoopy369@GMAIL.COM> wrote:
>No reason to use loop counting unless you are either using this in some
>other analysis or doing it for a class... PROC MEANS or PROC FREQ or PROC
>TABULATE etc. will all happily count things for you. Just define a
variable
>(or variables) for each time period (say, WEEK, MONTH, YEAR variables, each
>with the week #, month #, and year #) , then use those in the TABLES or
>CLASS statement to get values for each period.
>
>-Joe
>
>On Tue, Feb 1, 2011 at 3:33 PM, Bill Westman <bdwebman@gmail.com> wrote:
>
>> I have the following data (millions of records):
>>
>> email activity_cd activity date
>> joe@hotmail.com, 5, search, 02/01/11,
>> joe@hotmail.com, 5, search, 02/01/11,
>> joe@hotmail.com, 5, search, 01/28/11,
>> joe@hotmail.com, 4, buy, 01/28/11,
>> joe@hotmail.com, 4, buy, 01/11/11,
>> joe@hotmail.com, 3, browse, 01/05/11
>>
>> (multiple email addresses)
>>
>> What I'd like SAS to do is tell me the following:
>>
>> is the past week (-7day period), [joe@hotmail.com] searched 3 times and
>> bought 1 time. within the past month I've searched 3 times, bought 2
>> times and browsed once.
>>
>> How would I program that across the entire data set?
>>
>> Thanks!
>>
|