|
Hi, 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 Paul McGeoghan, Application Support Specialist (Statistics and Databases), University Infrastructure Group (UIG), Information Services Cardiff University Tel. 02920 875035 |
|
Paul,
Actually you want to number cases within group. There are several ways to do this. I'd do it this way. Let rec be the new case number variable. Compute rec=1. If (group eq lag(group)) rec=lag(rec)+1. The 'trick' is that with every case having the value of rec preset to 1, the first case in group B has rec=1 when the comparison is made, which fails. Gene Maguin >>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 |
|
In reply to this post by Paul Mcgeoghan
Gene,
Thanks, yes that is what I was looking for. ===================== 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 |
|
In reply to this post by Paul Mcgeoghan
Thanks,
The following syntax will produce Time 1 2 3 . . 82 1 2 3 . . 82 However, I now want to produce the following instead which represents 1-82 periods Time 07:01 07:06 07:11 . . 13:46 07:01 07:06 07:11 . . 13:46 I could use Value Labels to define each of the 82 periods. Any other way? ===================== 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 |
|
Administrator
|
In reply to this post by Paul Mcgeoghan
Since SPSS stores time as number of seconds since midnight (ie 12:00 Am = 0) it follows that 7:00 AM = 7 * 60 * 60 = 25200. And 5 minutes = 5 * 60 = 300 . ------------------------------------- Hence your equation = NewTime = 25200 + Time * 300 . So in SPSS: COMPUTE NewTime = 25200 + Time * 300 . FORMAT NewTime (TIME5). ------------------------------------ HTH, David ------------- Thanks, The following syntax will produce Time 1 2 3 . . 82 1 2 3 . . 82 However, I now want to produce the following instead which represents 1-82 periods Time 07:01 07:06 07:11 . . 13:46 07:01 07:06 07:11 . . 13:46
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
|
In reply to this post by Paul Mcgeoghan
At 09:07 AM 3/26/2009, Paul McGeoghan wrote:
>However, I now want to produce the following which represents 1-82 periods > >Time >07:01 >07:06 David Marso's given you a solution. However, I recommend using SPSS time functions instead of calculating with seconds. The meaning of the code is much clearer, and it's much easier to write accurately. This is Gene Maguin's syntax, modified to increment by 5 minutes instead of 1 unit: NUMERIC tod(TIME5). Compute tod=TIME.HMS(7,1). If (group eq lag(group)) tod=lag(tod)+TIME.HMS(0,5). >07:11 >. >. >13:46 >07:01 >07:06 >07:11 >. >. >13:46 >I could use Value Labels to define each of the 82 periods. Any other way? > >===================== >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 >--=======AVGMAIL-49CBACCD0000======= >Content-Type: multipart/alternative; > boundary="=======AVGMAIL-49CBACCD0000=======" > >--=======AVGMAIL-49CBACCD0000======= >Content-Type: text/plain; x-avg=cert; charset=us-ascii >Content-Transfer-Encoding: quoted-printable >Content-Disposition: inline >Content-Description: "AVG certification" > > >No virus found in this incoming message. >Checked by AVG - www.avg.com >Version: 8.0.238 / Virus Database: 270.11.29/2024 - Release Date: 03/26/09 0= >7:12:00 > >--=======AVGMAIL-49CBACCD0000=======-- >--=======AVGMAIL-49CBACCD0000=======-- ===================== 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 |
| Free forum by Nabble | Edit this page |
