Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Re: a specific data management question

From   Dirk Enzmann <>
Subject   st: Re: a specific data management question
Date   Thu, 12 Aug 2010 14:02:37 +0200

"John F Hall" <> wrote:

Don't know about Stata as I don't have it here, but in SPSS:

count x = tag (1) .
crosstabs x by firm .        <various options for %, stats>

John, this is *Statalist*, not the SPSS discussion list. I strongly suggest *not* to present solutions using other software - otherwise we could also present solutions using R, SAS, ..., such solutions can't answer the question.

However, *if* you have reason to show this forum how a solution looks like in SPSS, it should really solve the problem. Because some reader might think that this is the case here (which it is not), I will present it - but mind, this is *Statalist*!

Grace's question was to create a *variable*, not to tabulate results. To create variables using summary statistics is notoriously difficult when using SPSS. An SPSS solution for this problem is:

/* --------- example begins here --------- */
data list list
    /firm tag.
begin data
1 0
1 .
1 1
1 1
1 3
2 0
2 1
2 2
2 3
3 0
3 0
3 .
end data.

compute id = $casenum.
compute firmtag = 10*firm+tag.
sort cases by firmtag.
AGGREGATE OUTFILE='C:\temp\AggrDat.tmp'
     /BY firmtag.
if value(tag) <> 1 n_ft=0.
if missing(tag) n_ft=0.
sort cases by firm.
AGGREGATE OUTFILE='C:\temp\AggrDat.tmp'
     /BY firm.
sort cases by id.
add files
   /drop id firmtag n_ft.
erase file = 'C:\temp\AGGRDAT.TMP'.
/* ---------- example ends here ---------- */.

But please, let us *not* discuss this solution here but move to the SPSS discussion list if you feel that this is necessary.


Dr. Dirk Enzmann
Institute of Criminal Sciences
Dept. of Criminology
Rothenbaumchaussee 33
D-20148 Hamburg

phone: +49-(0)40-42838.7498 (office)
       +49-(0)40-42838.4591 (Mrs Billon)
fax:   +49-(0)40-42838.2344
*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index