Easy problem

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

Easy problem

Charlotte-9
Hi list,

I have an easy problem (I reckon).  I need to generate a variable which
basically repeats the numbers 1, 2, 3.  In other words, I have a data file
in which each individual has three records (cases) and I just need to mark
up the different records as 1, 2, 3.  Could someone tell me how to do this
please?

Thanks,

Lou
Reply | Threaded
Open this post in threaded view
|

Re: Easy problem

Maguin, Eugene
Lou,

Let your id variable be ID and rec be your new record identifier.

Compute rec=1.
If (id eq lag(id)) rec=lag(rec)+1.


Gene Maguin
Reply | Threaded
Open this post in threaded view
|

Re: Easy problem

Edward Boadi
In reply to this post by Charlotte-9
This should work for you.

COMPUTE epis=1.
Sort cases by ID.
EXECUTE .
IF (ID= lag(ID))     epis = 1+lag(epis) .
EXECUTE .

NOTE: ID -is the individual identication number


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of
Lou
Sent: Tuesday, July 11, 2006 9:55 AM
To: [hidden email]
Subject: Easy problem


Hi list,

I have an easy problem (I reckon).  I need to generate a variable which
basically repeats the numbers 1, 2, 3.  In other words, I have a data file
in which each individual has three records (cases) and I just need to mark
up the different records as 1, 2, 3.  Could someone tell me how to do this
please?

Thanks,

Lou
Reply | Threaded
Open this post in threaded view
|

Re: Easy problem

Lemon, John S.
In reply to this post by Charlotte-9
Lou wrote:
> I have an easy problem (I reckon).  I need to generate a variable which
> basically repeats the numbers 1, 2, 3.  In other words, I have a data file
> in which each individual has three records (cases) and I just need to mark
> up the different records as 1, 2, 3.  Could someone tell me how to do this
> please?
>
Try this syntax code ( untested ).

COMPUTE COUNTER = 1.
IF ( ( MOD ( $CASENUM, 2 ) ) EQ 0 ) COUNTER = 2.
IF ( ( MOD ( $CASENUM, 3 ) ) EQ 0 ) COUNTER = 3.

Hope this helps


--

Best wishes

John S. Lemon                Mailto:[hidden email]
DISS - ASD (Computing)          Tel: +44 1224 273350
Aberdeen University - Scotland
                                Fax: +44 1224 273372
Reply | Threaded
Open this post in threaded view
|

Re: Easy problem

Simon Phillip Freidin
In reply to this post by Charlotte-9
http://www.spsstools.net/
SampleSyntax.htm#RankingLargestValuesSortingGrouping

Number 16: Number consecutively cases with the same id.SPS

On 11/07/2006, at 11:55 PM, Lou wrote:

> Hi list,
>
> I have an easy problem (I reckon).  I need to generate a variable
> which
> basically repeats the numbers 1, 2, 3.  In other words, I have a
> data file
> in which each individual has three records (cases) and I just need
> to mark
> up the different records as 1, 2, 3.  Could someone tell me how to
> do this
> please?
>
> Thanks,
>
> Lou
Reply | Threaded
Open this post in threaded view
|

Re: Easy problem

Charlotte-9
In reply to this post by Charlotte-9
Dear all,

Thanks very much for your help!  I was amazed by how many responses I got
in such a short space of time!!

All the best,

Lou

On Wed, 12 Jul 2006 00:03:08 +1000, Simon Freidin <[hidden email]>
wrote:

>http://www.spsstools.net/
>SampleSyntax.htm#RankingLargestValuesSortingGrouping
>
>Number 16: Number consecutively cases with the same id.SPS
>
>On 11/07/2006, at 11:55 PM, Lou wrote:
>
>> Hi list,
>>
>> I have an easy problem (I reckon).  I need to generate a variable
>> which
>> basically repeats the numbers 1, 2, 3.  In other words, I have a
>> data file
>> in which each individual has three records (cases) and I just need
>> to mark
>> up the different records as 1, 2, 3.  Could someone tell me how to
>> do this
>> please?
>>
>> Thanks,
>>
Reply | Threaded
Open this post in threaded view
|

Re: Easy problem

Monica Perry
In reply to this post by Charlotte-9
Hi Lou,
If you're not looking for syntax (or want to use GUI to go through the
steps and then paste the syntax), you can use identify duplicate cases.

Identify duplicate cases can be used if you have a common
identification number for each individual, such as student/patient ID or
social security number.

As you go through the steps select "Sequential count of matching case
in each group" under Variables To Create.  This will number all
occurances of the same ID number, as 1, 2, 3...if an ID number does not
have a match, it will be given a zero (but this really means there is
only 1 case).


Monica Perry
Title 1 Program Specialist
Pitt County Schools, Greenville NC
(252) 752-0124



>>> Lou <[hidden email]> 07/11/06 9:55 AM >>>

Hi list,

I have an easy problem (I reckon).  I need to generate a variable
which
basically repeats the numbers 1, 2, 3.  In other words, I have a data
file
in which each individual has three records (cases) and I just need to
mark
up the different records as 1, 2, 3.  Could someone tell me how to do
this
please?

Thanks,

Lou
Reply | Threaded
Open this post in threaded view
|

Re: Easy problem

Marks, Jim
In reply to this post by Charlotte-9
>This should work for you.

>COMPUTE epis=1.
>Sort cases by ID.
>EXECUTE .
>IF (ID= lag(ID))     epis = 1+lag(epis) .
>EXECUTE .

The "EXECUTE" after "SORT CASES" is unnecessary. The SORT CASES will
read the data file, and the COMPUTE will be run during that data pass.

(Borrowing Richard's soapbox )

--jim


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Edward Boadi
Sent: Tuesday, July 11, 2006 9:01 AM
To: [hidden email]
Subject: Re: Easy problem

This should work for you.

COMPUTE epis=1.
Sort cases by ID.
EXECUTE .
IF (ID= lag(ID))     epis = 1+lag(epis) .
EXECUTE .

NOTE: ID -is the individual identication number


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of
Lou
Sent: Tuesday, July 11, 2006 9:55 AM
To: [hidden email]
Subject: Easy problem


Hi list,

I have an easy problem (I reckon).  I need to generate a variable which
basically repeats the numbers 1, 2, 3.  In other words, I have a data
file in which each individual has three records (cases) and I just need
to mark up the different records as 1, 2, 3.  Could someone tell me how
to do this please?

Thanks,

Lou
Reply | Threaded
Open this post in threaded view
|

Re: Easy problem

Edward Boadi
In reply to this post by Charlotte-9
Thanks Jim for you observation. I agree with you , one should reduce the
number of "EXECUTE" in syntax to reduce processing time.

Edward.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of
Marks, Jim
Sent: Tuesday, July 11, 2006 10:27 AM
To: [hidden email]
Subject: Re: Easy problem


>This should work for you.

>COMPUTE epis=1.
>Sort cases by ID.
>EXECUTE .
>IF (ID= lag(ID))     epis = 1+lag(epis) .
>EXECUTE .

The "EXECUTE" after "SORT CASES" is unnecessary. The SORT CASES will
read the data file, and the COMPUTE will be run during that data pass.

(Borrowing Richard's soapbox )

--jim


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Edward Boadi
Sent: Tuesday, July 11, 2006 9:01 AM
To: [hidden email]
Subject: Re: Easy problem

This should work for you.

COMPUTE epis=1.
Sort cases by ID.
EXECUTE .
IF (ID= lag(ID))     epis = 1+lag(epis) .
EXECUTE .

NOTE: ID -is the individual identication number


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of
Lou
Sent: Tuesday, July 11, 2006 9:55 AM
To: [hidden email]
Subject: Easy problem


Hi list,

I have an easy problem (I reckon).  I need to generate a variable which
basically repeats the numbers 1, 2, 3.  In other words, I have a data
file in which each individual has three records (cases) and I just need
to mark up the different records as 1, 2, 3.  Could someone tell me how
to do this please?

Thanks,

Lou