|
Dear list: I have the following data set that I would like to create a new variable which would represent the number of records per subject.
ID DV1 01 10 01 14 01 09 02 05 03 18 03 23 03 16 03 09 04 02 04 31 05 13 etc. some subjects has 45 records I want it to look like the following: ID record DV1 01 1 10 01 2 14 01 3 09 02 1 05 03 1 18 03 2 23 03 3 16 03 4 09 04 1 02 04 2 31 05 1 13 etc. thanks for input. martin sherman >>> Error in line 4 of spssx-l.mailtpl: unknown formatting command <<< -> .................... <- |
|
----- Original Message -----
From: "Martin Sherman" <[hidden email]> To: <[hidden email]> Sent: Monday, October 15, 2007 2:16 PM Subject: creating sequence number for varying records per subject > Dear list: I have the following data set that I would like to create a new > variable which would represent the number of records per subject. > > ID DV1 > 01 10 > 01 14 > 01 09 > 02 05 > 03 18 > 03 23 > 03 16 > 03 09 > 04 02 > 04 31 > 05 13 > etc. some subjects has 45 records > > I want it to look like the following: > > ID record DV1 > 01 1 10 > 01 2 14 > 01 3 09 > 02 1 05 > 03 1 18 > 03 2 23 > 03 3 16 > 03 4 09 > 04 1 02 > 04 2 31 > 05 1 13 > etc. > > thanks for input. martin sherman > > >>>> Error in line 4 of spssx-l.mailtpl: unknown formatting command <<< > -> .................... <- > > >>> Error in line 4 of spssx-l.mailtpl: unknown formatting command <<< -> .................... <- |
|
In reply to this post by msherman
This is one way:
DATA LIST LIST /ID DV1. BEGIN DATA 01 10 01 14 01 09 02 05 03 18 03 23 03 16 03 09 04 02 04 31 05 13 END DATA. COMPUTE caseid=$CASENUM. RANK VARIABLES=caseid BY ID /RANK INTO record . -- Raynald Levesque www.spsstools.net On 10/15/07, Martin Sherman <[hidden email]> wrote: > > Dear list: I have the following data set that I would like to create a new > variable which would represent the number of records per subject. > > ID DV1 > 01 10 > 01 14 > 01 09 > 02 05 > 03 18 > 03 23 > 03 16 > 03 09 > 04 02 > 04 31 > 05 13 > etc. some subjects has 45 records > > I want it to look like the following: > > ID record DV1 > 01 1 10 > 01 2 14 > 01 3 09 > 02 1 05 > 03 1 18 > 03 2 23 > 03 3 16 > 03 4 09 > 04 1 02 > 04 2 31 > 05 1 13 > etc. > > thanks for input. martin sherman > > > >>> Error in line 4 of spssx-l.mailtpl: unknown formatting command <<< > -> .................... <- > > ===================== 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 |
|
Hi,
Just started using SPSS and have slight background in Macro programming through SAS. It's quite diff from what I've using for the past 4 yrs. Appreciate if u can extend some help. It's just quite simple actually (I think, I hope). I just really am lost what I'm doing wrong. I'm testing the ff. codes. DEFINE ! GETDAT (YYMM=!TOKENS(1)). GET FILE=!CONCAT('C:\DATA\STMT_',!YYMM,'.SAV'). !ENDDEFINE. !GETDAT YYMM=0606. I'm doing something else within the macro and it runs ok except for this part. Am trying to parameterize YYMM so I can just change it everytime I'd have to use another date for my analysis. Am guessing it has something to do with the quotes or something. Thnx. April ====================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 |
|
Hi April,
You are true, the problem is connected with missing quotes. Add a !quote() function and it will run correctly. I tested this: DEFINE !GETDAT (YYMM=!TOKENS(1)). GET FILE = !quote(!CONCAT('C:\Program Files\SPSS\Trends chapter ',!YYMM,'.SAV')). !ENDDEFINE. !GETDAT YYMM=12. Best regards Jan -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of April Vergara Sent: Tuesday, October 16, 2007 3:45 AM To: [hidden email] Subject: Libpath in Macro Parameters Hi, Just started using SPSS and have slight background in Macro programming through SAS. It's quite diff from what I've using for the past 4 yrs. Appreciate if u can extend some help. It's just quite simple actually (I think, I hope). I just really am lost what I'm doing wrong. I'm testing the ff. codes. DEFINE ! GETDAT (YYMM=!TOKENS(1)). GET FILE=!CONCAT('C:\DATA\STMT_',!YYMM,'.SAV'). !ENDDEFINE. !GETDAT YYMM=0606. I'm doing something else within the macro and it runs ok except for this part. Am trying to parameterize YYMM so I can just change it everytime I'd have to use another date for my analysis. Am guessing it has something to do with the quotes or something. Thnx. April ======= 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 _____ Tato zpráva a všechny připojené soubory jsou důvěrné a určené výlučně adresátovi(-ům). Jestliže nejste oprávněným adresátem, je zakázáno jakékoliv zveřejňování, zprostředkování nebo jiné použití těchto informací. Jestliže jste tento mail dostali neoprávněně, prosím, uvědomte odesilatele a smažte zprávu i přiložené soubory. Odesilatel nezodpovídá za jakékoliv chyby nebo opomenutí způsobené tímto přenosem. This message and any attached files are confidential and intended solely for the addressee(s). Any publication, transmission or other use of the information by a person or entity other than the intended addressee is prohibited. If you receive this in error please contact the sender and delete the message as well as all attached documents. The sender does not accept liability for any errors or omissions as a result of the transmission. -.- -- ===================== 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 |
