„partitioned“ id-variable

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

„partitioned“ id-variable

Jara Kampmann

Dear List,

 

I am about to set up an id-variable consisting of several parts. The code has to be composed of

3 digits for “country”

2 digits for “wave”

1 digit for “study”

4 digits for “continuous respondent number”.

Resulting in a code [cccc][ww][s][nnnn].

The first three parts are no problem. However, the last part is hideous. I need a continuous code per “cell”, e.g. respondents in Spain in wave 2 in study type 1 need to be counted from 1 to 1500.

I tried several variants with $casenum (i.e. do if; temp. sel if; split file), but $casenum does not react to anything but the case’s position in the file.

Unfortunately, it is no viable solution to split the file into several files (as this would have to be performed by our users).

Does anyone of you see a solution to this tricky job?

 

Best,

Jara

Reply | Threaded
Open this post in threaded view
|

RE: "partitioned" id-variable

Maguin, Eugene
Jara,
 
I understand your problem correctly, i think you need to construct a counting variable that resets when you encounter a different combination of country, wave, study. This question gets aske periodically and there may be several different ways of doing it. My way is this.
 
sort cases by country wave study.
** I'm assuming that the order of person within country-wave-study is irrelevant.
compute ccr=1.
if (country eq lag(country) and wave eq lag(wave) and study eq lag(study) ccr=1+lag(ccr).
 
You may want leading digits on the ccr variable. One way is 'N' format, as in format ccr(n4) or (n2). The other way, more obvious, is to start ccr at 101 or 1001 or 100000001, whatever.
 
Gene Maguin
 


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Jara Kampmann
Sent: Friday, March 18, 2011 1:48 PM
To: [hidden email]
Subject: „partitioned“ id-variable

Dear List,

I am about to set up an id-variable consisting of several parts. The code has to be composed of

3 digits for “country”

2 digits for “wave”

1 digit for “study”

4 digits for “continuous respondent number”.

Resulting in a code [cccc][ww][s][nnnn].

The first three parts are no problem. However, the last part is hideous. I need a continuous code per “cell”, e.g. respondents in Spain in wave 2 in study type 1 need to be counted from 1 to 1500.

I tried several variants with $casenum (i.e. do if; temp. sel if; split file), but $casenum does not react to anything but the case’s position in the file.

Unfortunately, it is no viable solution to split the file into several files (as this would have to be performed by our users).

Does anyone of you see a solution to this tricky job?

Best,

Jara

Reply | Threaded
Open this post in threaded view
|

Re: "partitioned" id-variable

John F Hall

Bit late to think straight but, try something like:

 

Compute serial = country *  1000000000 + wave *   1000000 + study * 10000  + respondent .

 

 

John Hall

[hidden email]

www.surveyresearch.weebly.com

 

 

 

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Gene Maguin
Sent: 18 March 2011 20:57
To: [hidden email]
Subject: RE: "partitioned" id-variable

 

Jara,

 

I understand your problem correctly, i think you need to construct a counting variable that resets when you encounter a different combination of country, wave, study. This question gets aske periodically and there may be several different ways of doing it. My way is this.

 

sort cases by country wave study.

** I'm assuming that the order of person within country-wave-study is irrelevant.

compute ccr=1.

if (country eq lag(country) and wave eq lag(wave) and study eq lag(study) ccr=1+lag(ccr).

 

You may want leading digits on the ccr variable. One way is 'N' format, as in format ccr(n4) or (n2). The other way, more obvious, is to start ccr at 101 or 1001 or 100000001, whatever.

 

Gene Maguin

 

 


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Jara Kampmann
Sent: Friday, March 18, 2011 1:48 PM
To: [hidden email]
Subject: „partitioned“ id-variable

Dear List,

I am about to set up an id-variable consisting of several parts. The code has to be composed of

3 digits for “country”

2 digits for “wave”

1 digit for “study”

4 digits for “continuous respondent number”.

Resulting in a code [cccc][ww][s][nnnn].

The first three parts are no problem. However, the last part is hideous. I need a continuous code per “cell”, e.g. respondents in Spain in wave 2 in study type 1 need to be counted from 1 to 1500.

I tried several variants with $casenum (i.e. do if; temp. sel if; split file), but $casenum does not react to anything but the case’s position in the file.

Unfortunately, it is no viable solution to split the file into several files (as this would have to be performed by our users).

Does anyone of you see a solution to this tricky job?

Best,

Jara

Reply | Threaded
Open this post in threaded view
|

Re: "partitioned" id-variable

John F Hall
In reply to this post by Maguin, Eugene

 

 

 

Just did a quickie on this with dummy data

 

111        51           6             9001

222        52           7             9002

333        53           8             9003

444        54           9             9003

 

 

compute serial = country *  10000000 + wave *   100000 + study * 10000  + respondent .

format serial (f10.0) .

list serial .

 

    serial

 

1115169001

2225279002

3335389003

4445499003

 

 

Number of cases read:  4    Number of cases listed:  4

 

 

Looks OK to me.  Just need to save with vars in different order so serial is first if needed.  If you need more help with anything more extensive, get back to me off-list: no charge!

 

 

John Hall

[hidden email]

www.surveyresearch.weebly.com

 

 

 

 

 

 

From: John F Hall [mailto:[hidden email]]
Sent: 18 March 2011 22:52
To: 'Gene Maguin'; '[hidden email]'
Subject: RE: "partitioned" id-variable

 

Bit late to think straight but, try something like:

 

Compute serial = country *  1000000000 + wave *   1000000 + study * 10000  + respondent .

 

 

John Hall

[hidden email]

www.surveyresearch.weebly.com

 

 

 

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Gene Maguin
Sent: 18 March 2011 20:57
To: [hidden email]
Subject: RE: "partitioned" id-variable

 

Jara,

 

I understand your problem correctly, i think you need to construct a counting variable that resets when you encounter a different combination of country, wave, study. This question gets aske periodically and there may be several different ways of doing it. My way is this.

 

sort cases by country wave study.

** I'm assuming that the order of person within country-wave-study is irrelevant.

compute ccr=1.

if (country eq lag(country) and wave eq lag(wave) and study eq lag(study) ccr=1+lag(ccr).

 

You may want leading digits on the ccr variable. One way is 'N' format, as in format ccr(n4) or (n2). The other way, more obvious, is to start ccr at 101 or 1001 or 100000001, whatever.

 

Gene Maguin

 

 


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Jara Kampmann
Sent: Friday, March 18, 2011 1:48 PM
To: [hidden email]
Subject: „partitioned“ id-variable

Dear List,

I am about to set up an id-variable consisting of several parts. The code has to be composed of

3 digits for “country”

2 digits for “wave”

1 digit for “study”

4 digits for “continuous respondent number”.

Resulting in a code [cccc][ww][s][nnnn].

The first three parts are no problem. However, the last part is hideous. I need a continuous code per “cell”, e.g. respondents in Spain in wave 2 in study type 1 need to be counted from 1 to 1500.

I tried several variants with $casenum (i.e. do if; temp. sel if; split file), but $casenum does not react to anything but the case’s position in the file.

Unfortunately, it is no viable solution to split the file into several files (as this would have to be performed by our users).

Does anyone of you see a solution to this tricky job?

Best,

Jara

Reply | Threaded
Open this post in threaded view
|

Automatic reply: "partitioned" id-variable

Kelly Vander Ley

I will be out of the office from Monday March 20th -March 24th, returning to the office on March 25th. I will have limited access to e-mail and will reply as quickly as possible.  If you need immediate assistance please call the main office number 503/223-8248 or 800/788-1887 and the receptionist will ensure that I get the message.  Thank you. Kelly