question about casenum and id

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

question about casenum and id

Sebastián Daza
dear,
I need to create id variable with the following ones characteristics:

id
1
1
1
1
1
2
2
2
2
2
3
3
3
3
3
...

that is to say that each 5 cases go counting the value...
some idea of as making it. greetings and thank you.

--
Sebastián Daza Aranzaes

Sebastián Daza Aranzaes
Instituto de Sociología UC
8-471 53 87 / 686 57 20 / Fax 5521834
[hidden email]



Reply | Threaded
Open this post in threaded view
|

Re: question about casenum and id

Beadle, ViAnn
Do you already have a data file to which you want to add the IDs?

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Sebastián Daza
Sent: Wednesday, March 07, 2007 4:53 PM
To: [hidden email]
Subject: question about casenum and id

 

dear,
I need to create id variable with the following ones characteristics:

id
1
1
1
1
1
2
2
2
2
2
3
3
3
3
3
...

that is to say that each 5 cases go counting the value...
some idea of as making it. greetings and thank you.

--



Sebastián Daza Aranzaes
Instituto de Sociología UC
8-471 53 87 / 686 57 20 / Fax 5521834
[hidden email]

 
Reply | Threaded
Open this post in threaded view
|

Re: question about casenum and id

Richard Ristow
In reply to this post by Sebastián Daza
At 05:53 PM 3/7/2007, Sebastián Daza wrote:

>I need to create id variable with the following ones characteristics:
>
>id
>1
>1
>1
>1
>1
>2
>2
>2
>2
>2
>that is to say that each 5 cases go counting the value...

If you need to make a new file with these in it,
use a LOOP in an INPUT PROGRAM. In an existing
file, the following works. SPSS 15 draft output
<WRR-not saved separately>:

DATA LIST FIXED
    /SERIAL  01-03
     Greek   04-11 (A).

Data List will read 1 records from the command file

Variable          Rec   Start     End  Format

SERIAL              1       1       3  F3.0
Greek               1       4      11  A8

BEGIN DATA
1  Alpha
2  Beta
3  Gamma
4  Delta
5  Epsilon
6  Zeta
7  Eta
8  Theta
9  Iota
10 Kappa
11 Lambda
12 Mu
13 Nu
14 Xi
15 Omikron
16 Pi
17 Rho
18 Sigma
19 Tau
20 Upsilon
21 Phi
22 Chi
23 Psi
24 Omega
END DATA.

NUMERIC BY_FIVE (F3).
COMPUTE BY_FIVE = 1+TRUNC(($CASENUM-1)/5).

LIST.

List
|-----------------------------|---------------------------|
|Output Created               |07-MAR-2007 19:57:52       |
|-----------------------------|---------------------------|
SERIAL Greek    BY_FIVE

     1  Alpha        1
     2  Beta         1
     3  Gamma        1
     4  Delta        1
     5  Epsilon      1
     6  Zeta         2
     7  Eta          2
     8  Theta        2
     9  Iota         2
    10  Kappa        2
    11  Lambda       3
    12  Mu           3
    13  Nu           3
    14  Xi           3
    15  Omikron      3
    16  Pi           4
    17  Rho          4
    18  Sigma        4
    19  Tau          4
    20  Upsilon      4
    21  Phi          5
    22  Chi          5
    23  Psi          5
    24  Omega        5

Number of cases read:  24    Number of cases listed:  24
Reply | Threaded
Open this post in threaded view
|

Re: question about casenum and id

Albert-Jan Roskam
In reply to this post by Beadle, ViAnn
Hi,

I was thinking of something along the following line:

loop #i = 1 to ($casenum / 5 + 1).
loop #j = 1 to 5.
compute id = #i.
end loop.
end loop.
exe.

Problem is, that the first set of ids has four, not
five, units. Maybe this will still help you find the
right solution.

Albert-Jan

--- "Beadle, ViAnn" <[hidden email]> wrote:

> Do you already have a data file to which you want to
> add the IDs?
>
>
>
> From: SPSSX(r) Discussion
> [mailto:[hidden email]] On Behalf Of
> Sebasti�n Daza
> Sent: Wednesday, March 07, 2007 4:53 PM
> To: [hidden email]
> Subject: question about casenum and id
>
>
>
> dear,
> I need to create id variable with the following ones
> characteristics:
>
> id
> 1
> 1
> 1
> 1
> 1
> 2
> 2
> 2
> 2
> 2
> 3
> 3
> 3
> 3
> 3
> ...
>
> that is to say that each 5 cases go counting the
> value...
> some idea of as making it. greetings and thank you.
>
> --
>
>
>
> Sebasti�n Daza Aranzaes
> Instituto de Sociolog�a UC
> 8-471 53 87 / 686 57 20 / Fax 5521834
> [hidden email]
>
>
>


Cheers!
Albert-Jan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Did you know that 87.166253% of all statistics claim a precision of results that is not justified by the method employed? [HELMUT RICHTER]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



____________________________________________________________________________________
8:00? 8:25? 8:40? Find a flick in no time
with the Yahoo! Search movie showtime shortcut.
http://tools.search.yahoo.com/shortcuts/#news
Reply | Threaded
Open this post in threaded view
|

Re: question about casenum and id

Richard Ristow
At 10:01 AM 3/8/2007, Albert-jan Roskam wrote:

>I was thinking of something along the following line:
>
>loop #i = 1 to ($casenum / 5 + 1).
>.  loop #j = 1 to 5.
>.     compute id = #i.
>.  end loop.
>end loop.
>
>Problem is, that the first set of ids has four, not five, units.

That got me, too, the first time; I corrected, in what I posted. The
correct expression is "(($casenum-1) / 5 + 1)".

But neither loop is doing anything for you. The inner loop, especially;
it performs exactly the same COMPUTE statement five times.

The outer loop is doing a little, in that if, say, $casenum=3, it
becomes (correcting the expression)

loop #i = 1 to ((3-1)/ 5 + 1).
or
loop #i = 1 to 1.4.

Then the last loop pass is for #i=1, and you get the right value of
'id'. But you've gone through as many loop passes as the value of 'id',
to get there;

TRUNC(($casenum-1) / 5 + 1)

gets you the same result, in one step.
Reply | Threaded
Open this post in threaded view
|

Re: question about casenum and id

Albert-Jan Roskam
Ah, simplicity, parsimony, elegance! Nice solution!

Albert-Jan



--- Richard Ristow <[hidden email]> wrote:

> At 10:01 AM 3/8/2007, Albert-jan Roskam wrote:
>
> >I was thinking of something along the following
> line:
> >
> >loop #i = 1 to ($casenum / 5 + 1).
> >.  loop #j = 1 to 5.
> >.     compute id = #i.
> >.  end loop.
> >end loop.
> >
> >Problem is, that the first set of ids has four, not
> five, units.
>
> That got me, too, the first time; I corrected, in
> what I posted. The
> correct expression is "(($casenum-1) / 5 + 1)".
>
> But neither loop is doing anything for you. The
> inner loop, especially;
> it performs exactly the same COMPUTE statement five
> times.
>
> The outer loop is doing a little, in that if, say,
> $casenum=3, it
> becomes (correcting the expression)
>
> loop #i = 1 to ((3-1)/ 5 + 1).
> or
> loop #i = 1 to 1.4.
>
> Then the last loop pass is for #i=1, and you get the
> right value of
> 'id'. But you've gone through as many loop passes as
> the value of 'id',
> to get there;
>
> TRUNC(($casenum-1) / 5 + 1)
>
> gets you the same result, in one step.
>
>
>
>


Cheers!
Albert-Jan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Did you know that 87.166253% of all statistics claim a precision of results that is not justified by the method employed? [HELMUT RICHTER]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



____________________________________________________________________________________
Bored stiff? Loosen up...
Download and play hundreds of games for free on Yahoo! Games.
http://games.yahoo.com/games/front