Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Re: a specific data management question
From
Dirk Enzmann <[email protected]>
To
[email protected]
Subject
st: Re: a specific data management question
Date
Thu, 12 Aug 2010 14:02:37 +0200
"John F Hall" <[email protected]> wrote:
http://www.hsph.harvard.edu/cgi-bin/lwgate/STATALIST/archives/statalist.1008/date/article-530.html
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'
/BREAK=firmtag
/n_ft=N.
MATCH FILES
/FILE=*
/TABLE='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'
/BREAK=firm
/tag1=max(n_ft).
MATCH FILES
/FILE=*
/TABLE='C:\temp\AGGRDAT.TMP'
/BY firm.
sort cases by id.
add files
/file=*
/drop id firmtag n_ft.
erase file = 'C:\temp\AGGRDAT.TMP'.
list.
/* ---------- 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.
Dirk
========================================
Dr. Dirk Enzmann
Institute of Criminal Sciences
Dept. of Criminology
Rothenbaumchaussee 33
D-20148 Hamburg
Germany
phone: +49-(0)40-42838.7498 (office)
+49-(0)40-42838.4591 (Mrs Billon)
fax: +49-(0)40-42838.2344
email: [email protected]
http://www2.jura.uni-hamburg.de/instkrim/kriminologie/Mitarbeiter/Enzmann/Enzmann.html
========================================
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/