Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Compare to data files

7 views
Skip to first unread message

santc

unread,
Jan 18, 2012, 2:00:42 PM1/18/12
to
Hi,
I have about 500 ip addresses of the visitors of a website. Also I
have another set of address of those who visited another site. I just
want to compare how many have visited both sites. There may be less
than 100 common visitors. And there may be multiple visits.

first list
**.7.157.50
**.198.151.36
**.255.237.222
**.78.82.128
**.77.16.214
**.41.235.103
**.44.176.201
**.7.17.76
**.61.34.239

second list
**.7.17.75
**.44.141.77
**.100.108.176
**.7.157.50
**.126.10.48
**.44.176.201
**.44.176.201

Can anybody please help?

Bruce Weaver

unread,
Jan 18, 2012, 5:58:31 PM1/18/12
to
From what you've said, the key steps are 1) getting rid of duplicate IP
addresses, and 2) merging the files using MATCH FILES BY IP with the /IN
sub-command added to flag the sources of the records. IP addresses that
visited both sites will have both of those flags = 1. Here's an example
using your sample data.


* Read sample data into 2 datasets.

new file.
dataset close all.

data list list / IP (a25).
begin data
**.7.157.50
**.198.151.36
**.255.237.222
**.78.82.128
**.77.16.214
**.41.235.103
**.44.176.201
**.7.17.76
**.61.34.239
end data.
dataset name site1.

data list list / IP (a25).
begin data
**.7.17.75
**.44.141.77
**.100.108.176
**.7.157.50
**.126.10.48
**.44.176.201
**.44.176.201
end data.
dataset name site2.

* Get rid of duplicate IP addresses in first dataset.
dataset activate site1.
sort cases by IP.
match files
file = * /
by IP /
first = firstrec.
select if firstrec. /* get rid of duplicates.
execute.

* Get rid of duplicate IP addresses in second dataset.
dataset activate site2.
sort cases by IP.
match files
file = * /
by IP /
first = firstrec.
select if firstrec. /* get rid of duplicates.
execute.

* Merge the files, matching on IP address.
* Use /IN to flag source of records.

match files
file = 'site1' / in = site1 /
file = 'site2' / in = site2 /
by IP .
execute.
dataset name merged.

* Original datasets not needed, so close them.

dataset close site1.
dataset close site2.

* Compute flag for cases with IP address in both datasets.
* Then format variables, apply labels, and display results.

compute bothsites = site1 and site2.
formats bothsites (f1.0).
value labels site1 site2 bothsites 0 'No' 1 'Yes' .
frequencies site1 site2 bothsites.

* Crosstabs also works well for this.

crosstabs site1 by site2.


HTH.


--
Bruce Weaver
bwe...@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/Home
"When all else fails, RTFM."

David

unread,
Jan 19, 2012, 3:05:18 PM1/19/12
to
ADD FILES / FILE 'site1.sav' /IN=@f1@/ FILE 'site2.sav'/IN=@f2@.
AGGREGATE OUTFILE * / BREAK ip / @f1@ @f2@ = MAX(@f1@ @f2@).
SELECT IF @f1@ AND @f2@.
> bwea...@lakeheadu.cahttp://sites.google.com/a/lakeheadu.ca/bweaver/Home

iPathram Portal

unread,
Jan 24, 2012, 1:44:02 PM1/24/12
to
Thank you very much
0 new messages