Date: Thu, 1 May 2003 16:56:15 -0400
Reply-To: Richard Ristow <firstname.lastname@example.org>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Richard Ristow <email@example.com>
Subject: Re: Dynamic Variable Creation
In-Reply-To: <firstname.lastname@example.org .edu>
Content-Type: text/plain; charset="us-ascii"; format=flowed
At 12:30 PM 5/1/2003 -0400, Richard J. Reeves wrote:
>I have a dataset from a server that has visiting history. I am trying
>to create counter variables to track how many times a given user
>visits a given page. Currently the data is in this format:
>There are over 1000 pages and over 1000 user ides and both change
>regularly so I would like a way to dynamically code the variable names
>(or labels) so that I know how many times a person visited a given
>page. I tried using some vectors with a double loop but could not
>quite get there. I am wonder if there is a script solution or of this
>simply can't be done.
To start with, the natural solutions do not create multitudes of
variables. If you want one CASE to count the number of times a given
user visits a page, it's very quick:
AGGREGATE /OUTFILE=*/BREAK=ID PAGE/N_VISITS = N.
You can write a separate file instead of using "OUTFILE=*", of course.
If you really want a bunch of variables, look at CASESTOVARS, which
will create variables dynamically from the data. Here's a response to a
similar query, posted by Karel Asselberghs
<asselberghs@XS4ALL.NL> Mon, 10 Mar 2003 13:25:15 +0100 ("Re:
Aggregate functions") -- I've changed variable names for your case:
>split file by ID.
>split file off.
That should (I'm a couple of releases back, and don't have CASESTOVARS)
give you one case per ID, and one variable per page visited.