Data reshape query

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

Data reshape query

Mark Webb-5
How would one convert data set A to data set B in SPSS?

Data set A
Record Age Area Q1 Q2 Q3 Q4
1              16     A    1   2    3    4
2              25     B         5          8
3              41     C               7     

Data set B
Record Age Area Question Response
1             16      A            Q1              1
1             16      A            Q2              2 
1             16      A            Q3              3
1             16      A            Q4              4
2              25     B            Q2              5
2              25     B            Q4              8
3              41     C            Q3              7

Thanks in advance
Regards
-- 
Mark Webb

Line +27 (21) 786 1239
Cell +27 (72) 199 1000 [Poor reception]
Fax  +27 (86) 260 1946 

Skype       tomarkwebb 
Email       [hidden email] 
===================== 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: Data reshape query

Jignesh Sutar
Look up VARSTOCASES

On 30 March 2016 at 12:17, Mark Webb <[hidden email]> wrote:
How would one convert data set A to data set B in SPSS?

Data set A
Record Age Area Q1 Q2 Q3 Q4
1              16     A    1   2    3    4
2              25     B         5          8
3              41     C               7     

Data set B
Record Age Area Question Response
1             16      A            Q1              1
1             16      A            Q2              2 
1             16      A            Q3              3
1             16      A            Q4              4
2              25     B            Q2              5
2              25     B            Q4              8
3              41     C            Q3              7

Thanks in advance
Regards
-- 
Mark Webb

Line +27 (21) 786 1239
Cell +27 (72) 199 1000 [Poor reception]
Fax  +27 (86) 260 1946 

Skype       tomarkwebb 
Email       [hidden email] 
===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: Data reshape query

Jignesh Sutar
It's the INDEX subcommand that you require:


DATA LIST FREE / Record Age Q1 Q2 Q3 Q4.
BEGIN DATA.    
1 16 1 2 3 4
2 17 5 6 7 8
3 18 9 10 11 12.
END DATA.

VARSTOCASES /MAKE Response FROM Q1 TO Q4 /index=Question(Response).




On 30 March 2016 at 12:38, Mark Webb <[hidden email]> wrote:
I have done so but can't get the Question column in.
Regards
Mark Webb

Line +27 (21) 786 1239
Cell +27 (72) 199 1000 [Poor reception]
Fax  +27 (86) 260 1946 

Skype       tomarkwebb 
Email       [hidden email] 
On 2016/03/30 01:33 PM, Jignesh Sutar wrote:
Look up VARSTOCASES

On 30 March 2016 at 12:17, Mark Webb <[hidden email]> wrote:
How would one convert data set A to data set B in SPSS?

Data set A
Record Age Area Q1 Q2 Q3 Q4
1              16     A    1   2    3    4
2              25     B         5          8
3              41     C               7     

Data set B
Record Age Area Question Response
1             16      A            Q1              1
1             16      A            Q2              2 
1             16      A            Q3              3
1             16      A            Q4              4
2              25     B            Q2              5
2              25     B            Q4              8
3              41     C            Q3              7

Thanks in advance
Regards
-- 
Mark Webb

Line +27 (21) 786 1239
Cell +27 (72) 199 1000 [Poor reception]
Fax  +27 (86) 260 1946 

Skype       tomarkwebb 
Email       [hidden email] 
===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: Data reshape query

Jignesh Sutar
For dealing with missings review the NULL subcommand.

On 30 March 2016 at 13:04, Mark Webb <[hidden email]> wrote:
Thank you Jignesh - works well.
One issue though - how do I handle missing responses? - in my example record 3 only has one response - is there a way to accommodate missing data?

Thanks again
Mark Webb

Line +27 (21) 786 1239
Cell +27 (72) 199 1000 [Poor reception]
Fax  +27 (86) 260 1946 

Skype       tomarkwebb 
Email       [hidden email] 
On 2016/03/30 01:52 PM, Jignesh Sutar wrote:
It's the INDEX subcommand that you require:


DATA LIST FREE / Record Age Q1 Q2 Q3 Q4.
BEGIN DATA.    
1 16 1 2 3 4
2 17 5 6 7 8
3 18 9 10 11 12.
END DATA.

VARSTOCASES /MAKE Response FROM Q1 TO Q4 /index=Question(Response).




On 30 March 2016 at 12:38, Mark Webb <[hidden email]> wrote:
I have done so but can't get the Question column in.
Regards
Mark Webb

Line +27 (21) 786 1239
Cell +27 (72) 199 1000 [Poor reception]
Fax  +27 (86) 260 1946 

Skype       tomarkwebb 
Email       [hidden email] 
On 2016/03/30 01:33 PM, Jignesh Sutar wrote:
Look up VARSTOCASES

On 30 March 2016 at 12:17, Mark Webb <[hidden email][hidden email]> wrote:
How would one convert data set A to data set B in SPSS?

Data set A
Record Age Area Q1 Q2 Q3 Q4
1              16     A    1   2    3    4
2              25     B         5          8
3              41     C               7     

Data set B
Record Age Area Question Response
1             16      A            Q1              1
1             16      A            Q2              2 
1             16      A            Q3              3
1             16      A            Q4              4
2              25     B            Q2              5
2              25     B            Q4              8
3              41     C            Q3              7

Thanks in advance
Regards
-- 
Mark Webb

Line +27 (21) 786 1239
Cell +27 (72) 199 1000 [Poor reception]
Fax  +27 (86) 260 1946 

Skype       tomarkwebb 
Email       [hidden email] 
===================== 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