help needed parsing variable ID into separate variables

  • Follow


thanks in advance for any assistance.  we are prepping some data for HLM.  participants completed up to 8 weekly diaries.  there is an ID called UserName that is as follows:

11
12
13
14
...
2991
2992
2993
2995
2997

the last digit always contains the digit 1 through 8 which indicates the week of the diary - it may not be sequential (5 might be missing for example).  The first 1 to 3 characters (depends) are the participant ID.

we want to find the simplest/most efficient way to pull out the participant ID (which varys in length unfortunately) and the weeknumber (always in the last position).  

any advice - directions?  
0
Reply Holly 2/21/2011 10:26:19 PM

On 21/02/2011 5:26 PM, Holly wrote:
> thanks in advance for any assistance.  we are prepping some data for HLM.  participants completed up to 8 weekly diaries.  there is an ID called UserName that is as follows:
>
> 11
> 12
> 13
> 14
> ..
> 2991
> 2992
> 2993
> 2995
> 2997
>
> the last digit always contains the digit 1 through 8 which indicates the week of the diary - it may not be sequential (5 might be missing for example).  The first 1 to 3 characters (depends) are the participant ID.
>
> we want to find the simplest/most efficient way to pull out the participant ID (which varys in length unfortunately) and the weeknumber (always in the last position).
>
> any advice - directions?

I don't have SPSS on this machine, so the following is untested.  It 
also assumes that UserName is a numeric variable (not string).

compute ID = trunc(UserName/10).
compute Week = UserName - ID*10.

-- 
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/Home
"When all else fails, RTFM."
0
Reply Bruce 2/21/2011 11:27:33 PM


amazing. perfect.  most appreciated.  thank you!
0
Reply Holly 2/22/2011 3:53:03 AM

2 Replies
367 Views

(page loaded in 0.056 seconds)

Similiar Articles:













7/29/2012 11:17:21 PM


Reply: