creating a variable based on number of cases in a group

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

creating a variable based on number of cases in a group

Paul Mcgeoghan
Hi,

(Posting this again as I see the font formatting from my mailer was
completely messed up first time)

I want to work out the number of cases in each group and then store that as
a variable.
So I have variable Group
A has 20 cases
B has 30 cases

I want data to look like:
A  1
A  2
A  3
.
.
.
A 20
B 1
B 2
.
.
B 30

What is easiest way of achieving this in SPSS?
Thanks,
Paul

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: creating a variable based on number of cases in a group

Clive Downs
Paul,

I interpreted your message a bit differently to Gene.
Is the following what you want?

1) syntax to produce in-line sample data:

DATA LIST FREE/  group (A1)  value.
BEGIN DATA

a 25
a 43
a 76
a 205
b 43
b 76
b 87
END DATA.
DATASET NAME groupdata.
AGGREGATE
  /OUTFILE=*
  MODE=ADDVARIABLES
  /BREAK=group
  /grpsize = NU(value).
EXE.

2) will produce the following output

group                 value          grpsize
a               25         4
a               43         4
a               76         4
a              205         4
b               43         3
b               76         3
b               87         3

- not exactly what you described, but is this what you wanted?

Regards

Clive.


On Tue, 24 Mar 2009 07:17:01 -0400, Paul McGeoghan
<[hidden email]> wrote:

>Hi,
>
>(Posting this again as I see the font formatting from my mailer was
>completely messed up first time)
>
>I want to work out the number of cases in each group and then store that as
>a variable.
>So I have variable Group
>A has 20 cases
>B has 30 cases
>
>I want data to look like:
>A  1
>A  2
>A  3
>.
>.
>.
>A 20
>B 1
>B 2
>.
>.
>B 30
>
>What is easiest way of achieving this in SPSS?
>Thanks,
>Paul
>
>=====================
>To manage your subscription to SPSSX-L, send a message to
>[hidden email] (not to SPSSX-L), with no body text except the
>command. To leave the list, send the command
>SIGNOFF SPSSX-L
>For a list of commands to manage subscriptions, send the command
>INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD