reference or index??????

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

reference or index??????

Samuel Solomon
Hi everyone,

 

Is there a reference or index of position for a specific case in a
variable? Let's say I have a variable with ten observations (cases). If
I want to flag the sixth case how do I pinpoint it's position. What if I
have tens of thousands of observation?

 

Regards,

Samuel.

 
Reply | Threaded
Open this post in threaded view
|

Re: reference or index??????

Marta Garcia-Granero
Hi Samuel

COMPUTE flag=($casenum=6).

This code will compute a new variable with value=1 for case number 6 and
0 for the remainder cases.
> Is there a reference or index of position for a specific case in a
> variable? Let's say I have a variable with ten observations (cases). If
> I want to flag the sixth case how do I pinpoint it's position. What if I
> have tens of thousands of observation?
>
Regards,
Marta Garcia-Granero
Reply | Threaded
Open this post in threaded view
|

Re: reference or index??????

Marta Garcia-Granero
In reply to this post by Samuel Solomon
Hi Samuel:

Questions should be addressed to the list, please. I'm not really sure I
understand your question correctly. According the unsolicited Excel file
you sent to me, what you want is fill blanks in a variable, nothing to
do with pinpointing a given case (your original question to the list).
For the future, present some sample data with your question, indicating
your goal.

Extracting data from the Excel file, I think your goal is getting from this:

com_nub         percentiles     itemprice
 01029000
        1,00


        ,00

        5       19,63

        25      19,63

        50      19,63

        75      19,63

        95      19,63
 01039100
        1,00


        ,00

        5       4,31

        25      4,31

        50      4,31

        75      4,31

        95      4,31
 01041000
        1,00


        ,00

        5       19,64

        25      19,64

        50      19,64

        75      19,64

        95      19,64
 01042000
        1,00


        ,00

        5       85,00

        25      85,00

        50      85,00

        75      85,00

        95      85,00


To this:

com_nub         percentiles     itemprice
 01029000
        1,00
 01029000
        ,00
 01029000       5       19,63
 01029000       25      19,63
 01029000       50      19,63
 01029000       75      19,63
 01029000       95      19,63
 01039100
        1,00
 01039100
        ,00
 01039100       5       4,31
 01039100       25      4,31
 01039100       50      4,31
 01039100       75      4,31
 01039100       95      4,31
 01041000
        1,00
 01041000
        ,00
 01041000       5       19,64
 01041000       25      19,64
 01041000       50      19,64
 01041000       75      19,64
 01041000       95      19,64
 01042000
        1,00
 01042000
        ,00
 01042000       5       85,00
 01042000       25      85,00
 01042000       50      85,00
 01042000       75      85,00
 01042000       95      85,00


OK, let's work on it:

* Your sample data *.
PRESERVE.
SET ERROS=NONE.
DATA LIST LIST/com_nub(N9) percentiles(F2) itemprice(F8.2).
BEGIN DATA
1029000    .    1,00
.    .    ,00
.    5,00    19,63
.    25,00    19,63
.    50,00    19,63
.    75,00    19,63
.    95,00    19,63
1039100    .    1,00
.    .    ,00
.    5,00    4,31
.    25,00    4,31
.    50,00    4,31
.    75,00    4,31
.    95,00    4,31
1041000    .    1,00
.    .    ,00
.    5,00    19,64
.    25,00    19,64
.    50,00    19,64
.    75,00    19,64
.    95,00    19,64
1042000    .    1,00
.    .    ,00
.    5,00    85,00
.    25,00    85,00
.    50,00    85,00
.    75,00    85,00
.    95,00    85,00
END DATA.
RESTORE.

* Filling the blanks *.
IF MISSING(com_nub) com_nub=LAG(com_nub).
LIST.

HTH,
Marta

> Dear Gracia-Granero,
>
> COMPUTE flag=($casenum=6) would exactly locate the desired case but what
> I really want is ...., have you seen the attached .xls file? If so that
> is exactly what I was trying to say. I want to fill the black rows(where
> the arrow starts) with  figures in red (where the arrow points) in the
> attached file. I could have done it manually but it would be an insult
> to modern supper computers.
>
> Thanks,
> Samuel.
>
>
>
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
> Marta Garcia-Granero
> Sent: Tuesday, July 17, 2007 6:40 PM
> To: [hidden email]
> Subject: Re: reference or index??????
>
> Hi Samuel
>
> COMPUTE flag=($casenum=6).
>
> This code will compute a new variable with value=1 for case number 6 and
> 0 for the remainder cases.
>
> Is there a reference or index of position for a specific case in a
>
> variable? Let's say I have a variable with ten observations (cases).
>
> If I want to flag the sixth case how do I pinpoint it's position. What if
>
> I have tens of thousands of observation?
>
>
Reply | Threaded
Open this post in threaded view
|

Re: reference or index??????

Samuel Solomon
Hi Garcia-Granero,

It works! I should have cut to the chase when asking.

Thanks,
Samuel

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Marta Garcia-Granero
Sent: Wednesday, July 18, 2007 11:24 AM
To: [hidden email]
Subject: Re: reference or index??????

Hi Samuel:

Questions should be addressed to the list, please. I'm not really sure I
understand your question correctly. According the unsolicited Excel file
you sent to me, what you want is fill blanks in a variable, nothing to
do with pinpointing a given case (your original question to the list).
For the future, present some sample data with your question, indicating
your goal.

Extracting data from the Excel file, I think your goal is getting from
this:

com_nub         percentiles     itemprice
 01029000
        1,00


        ,00

        5       19,63

        25      19,63

        50      19,63

        75      19,63

        95      19,63
 01039100
        1,00


        ,00

        5       4,31

        25      4,31

        50      4,31

        75      4,31

        95      4,31
 01041000
        1,00


        ,00

        5       19,64

        25      19,64

        50      19,64

        75      19,64

        95      19,64
 01042000
        1,00


        ,00

        5       85,00

        25      85,00

        50      85,00

        75      85,00

        95      85,00


To this:

com_nub         percentiles     itemprice
 01029000
        1,00
 01029000
        ,00
 01029000       5       19,63
 01029000       25      19,63
 01029000       50      19,63
 01029000       75      19,63
 01029000       95      19,63
 01039100
        1,00
 01039100
        ,00
 01039100       5       4,31
 01039100       25      4,31
 01039100       50      4,31
 01039100       75      4,31
 01039100       95      4,31
 01041000
        1,00
 01041000
        ,00
 01041000       5       19,64
 01041000       25      19,64
 01041000       50      19,64
 01041000       75      19,64
 01041000       95      19,64
 01042000
        1,00
 01042000
        ,00
 01042000       5       85,00
 01042000       25      85,00
 01042000       50      85,00
 01042000       75      85,00
 01042000       95      85,00


OK, let's work on it:

* Your sample data *.
PRESERVE.
SET ERROS=NONE.
DATA LIST LIST/com_nub(N9) percentiles(F2) itemprice(F8.2).
BEGIN DATA
1029000    .    1,00
.    .    ,00
.    5,00    19,63
.    25,00    19,63
.    50,00    19,63
.    75,00    19,63
.    95,00    19,63
1039100    .    1,00
.    .    ,00
.    5,00    4,31
.    25,00    4,31
.    50,00    4,31
.    75,00    4,31
.    95,00    4,31
1041000    .    1,00
.    .    ,00
.    5,00    19,64
.    25,00    19,64
.    50,00    19,64
.    75,00    19,64
.    95,00    19,64
1042000    .    1,00
.    .    ,00
.    5,00    85,00
.    25,00    85,00
.    50,00    85,00
.    75,00    85,00
.    95,00    85,00
END DATA.
RESTORE.

* Filling the blanks *.
IF MISSING(com_nub) com_nub=LAG(com_nub).
LIST.

HTH,
Marta

> Dear Gracia-Granero,
>
> COMPUTE flag=($casenum=6) would exactly locate the desired case but
what
> I really want is ...., have you seen the attached .xls file? If so
that
> is exactly what I was trying to say. I want to fill the black
rows(where

> the arrow starts) with  figures in red (where the arrow points) in the
> attached file. I could have done it manually but it would be an insult
> to modern supper computers.
>
> Thanks,
> Samuel.
>
>
>
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf
Of

> Marta Garcia-Granero
> Sent: Tuesday, July 17, 2007 6:40 PM
> To: [hidden email]
> Subject: Re: reference or index??????
>
> Hi Samuel
>
> COMPUTE flag=($casenum=6).
>
> This code will compute a new variable with value=1 for case number 6
and
> 0 for the remainder cases.
>
> Is there a reference or index of position for a specific case in a
>
> variable? Let's say I have a variable with ten observations (cases).
>
> If I want to flag the sixth case how do I pinpoint it's position. What
if
>
> I have tens of thousands of observation?
>
>