Restructure with two variables

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

Restructure with two variables

DKUKEC
Dear List,

I have reviewed NABBLE and Google without any luck.  I am unsure why the following is not working.  I am looking to restructure the following data so that there are 32 questions for each id and case - q1.for answer_s and q1
for answer_n , etc.   Any suggestions of where I am going wrong would be much appreciated.

Thank you in advance.
Damir

DATA LIST LIST / ID(F5.0) AGENCY(F2) CASE(F5.0) DATE (DATE11) QUESTION (A75) ANSWER_S (A4) ANSWER_N (F5.0) .
BEGIN DATA  
1234 13 2615 30-Sep-2014 q1.A- 9999 9999
1234 13 2615 30-Sep-2014 q2.A-DateRequested: 9999 9999
1234 13 2615 30-Sep-2014 q3.A-ContactedBy: 9999 9999
1234 13 2615 30-Sep-2014 q4.A-Eligible: 9999 9999
1234 13 2615 30-Sep-2014 q5.A-AppointmentDate: 9999 9999
1234 13 2615 30-Sep-2014 q6.A-ServiceRequested: 9999 9999
1234 13 2615 30-Sep-2014 q7.A-Indigent: 9999 9999
1234 13 2615 30-Sep-2014 q8.A-Status: 9999 9999
1234 13 2615 30-Sep-2014 q9.A-DateSenttoStateAttorney: 9999 9999
1234 13 2615 30-Sep-2014 q10.A-StateAttorneyApplication: 9999 9999
1234 13 2615 30-Sep-2014 q11.A-DateApplicationReceivedfromState: 9999 9999
1234 13 2615 30-Sep-2014 q12.A-DateSenttoFDLE: 9999 9999
1234 13 2615 30-Sep-2014 q13.A-DateReceivedBackfromFDLE: 9999 9999
1234 13 2615 30-Sep-2014 q14.A-FDLECertificate: 9999 9999
1234 13 2615 30-Sep-2014 q15.A-HearingDate: 9999 9999
1234 13 2615 30-Sep-2014 q16.A-Division: 9999 9999
END DATA .
EXECUTE .

SORT CASES BY ID CASE QUESTION  .
CASESTOVARS
 /ID = ID CASE  
 /INDEX = QUESTION    
 /GROUPBY = VARIABLE   .

EXECUTE .
Reply | Threaded
Open this post in threaded view
|

Re: Restructure with two variables

David Marso
Administrator
Pay attention to resulting variable names !!!
Look up AUTOFIX in the FM!
----
SORT CASES BY ID CASE QUESTION  .
COMPUTE Question = REPLACE(Question,"-","_").
COMPUTE  Question = REPLACE(Question,":","").
CASESTOVARS
 /ID =  ID CASE  
 /INDEX = Question  
 /FIXED= Agency Date
 /AUTOFIX=NO  
 /GROUPBY = VARIABLE   .
DKUKEC wrote
Dear List,

I have reviewed NABBLE and Google without any luck.  I am unsure why the following is not working.  I am looking to restructure the following data so that there are 32 questions for each id and case - q1.for answer_s and q1
for answer_n , etc.   Any suggestions of where I am going wrong would be much appreciated.

Thank you in advance.
Damir

DATA LIST LIST / ID(F5.0) AGENCY(F2) CASE(F5.0) DATE (DATE11) QUESTION (A75) ANSWER_S (A4) ANSWER_N (F5.0) .
BEGIN DATA  
1234 13 2615 30-Sep-2014 q1.A- 9999 9999
1234 13 2615 30-Sep-2014 q2.A-DateRequested: 9999 9999
1234 13 2615 30-Sep-2014 q3.A-ContactedBy: 9999 9999
1234 13 2615 30-Sep-2014 q4.A-Eligible: 9999 9999
1234 13 2615 30-Sep-2014 q5.A-AppointmentDate: 9999 9999
1234 13 2615 30-Sep-2014 q6.A-ServiceRequested: 9999 9999
1234 13 2615 30-Sep-2014 q7.A-Indigent: 9999 9999
1234 13 2615 30-Sep-2014 q8.A-Status: 9999 9999
1234 13 2615 30-Sep-2014 q9.A-DateSenttoStateAttorney: 9999 9999
1234 13 2615 30-Sep-2014 q10.A-StateAttorneyApplication: 9999 9999
1234 13 2615 30-Sep-2014 q11.A-DateApplicationReceivedfromState: 9999 9999
1234 13 2615 30-Sep-2014 q12.A-DateSenttoFDLE: 9999 9999
1234 13 2615 30-Sep-2014 q13.A-DateReceivedBackfromFDLE: 9999 9999
1234 13 2615 30-Sep-2014 q14.A-FDLECertificate: 9999 9999
1234 13 2615 30-Sep-2014 q15.A-HearingDate: 9999 9999
1234 13 2615 30-Sep-2014 q16.A-Division: 9999 9999
END DATA .
EXECUTE .

SORT CASES BY ID CASE QUESTION  .
CASESTOVARS
 /ID = ID CASE  
 /INDEX = QUESTION    
 /GROUPBY = VARIABLE   .

EXECUTE .
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Restructure with two variables

DKUKEC
Thank you David,

This did the trick... will look up autofix.

Damir