creating participant number with number and character

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

creating participant number with number and character

Jordan Kennedy
Hopefully quick and easy question. I have a large data set and I would like to have a participant ID that has a numeric value representing the case number but with a character that is the same for each participant. For example, something that looks like the following for the first 3 cases:

1p
2p
3p
...

Any quick way to do this would be much appreciated!

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: creating participant number with number and character

Bruce Weaver
Administrator
STRING ID (A8).
COMPUTE ID = LTRIM( CONCAT(STRING($CASENUM,F5.0), "p") ).
LIST VARIABLES=ID /CASES=FROM 1 TO 10.




Jordan Kennedy wrote

> Hopefully quick and easy question. I have a large data set and I would
> like to have a participant ID that has a numeric value representing the
> case number but with a character that is the same for each participant.
> For example, something that looks like the following for the first 3
> cases:
>
> 1p
> 2p
> 3p
> ...
>
> Any quick way to do this would be much appreciated!
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
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
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.
Reply | Threaded
Open this post in threaded view
|

Re: creating participant number with number and character

Maguin, Eugene
In reply to this post by Jordan Kennedy
Probably time get acquainted with the universals chapter section transformation expressions in the syntax reference manual.

String newid(a2).
Compute newid=concat(string,paticipantid,f1.0),'p').

I'm guessing your id values are more than 1 to 9 and if so, you'll need to adjust the string width and format of the string function. The other thing about this new id is that it won't sort 'right' and by right I mean that '10p' follows ' 1p' and precedes ' 2p'. If that doesn't matter then you're done. If it does, then I think the solution is to change the format from, for example, f2.0 to N2 so that leading zeros will be printed. I always fixed this problem a clumsier way rather than trying this method.
Gene Maguin

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Jordan Kristopher
Sent: Friday, July 24, 2020 1:20 PM
To: [hidden email]
Subject: creating participant number with number and character

Hopefully quick and easy question. I have a large data set and I would like to have a participant ID that has a numeric value representing the case number but with a character that is the same for each participant. For example, something that looks like the following for the first 3 cases:

1p
2p
3p
...

Any quick way to do this would be much appreciated!

=====================
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

=====================
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