I am trying to put all questions and answers for a given ID on a single row, but am having difficulties doing so. There are some other fields but the main ones are concerned with re-arranging the data are:CaseID QuestionText AnswerText. The other columns are TestPeriod, TestName, RecordPrimaryID CaseWorkDT AssignedOwner ManagerName Data I have is like this (with the additional columns but that's just extra noise at this point): CaseID QuestionText AnswerText 1111 Claim Pass 1111 Memos Pass 1111 Procedure Fail 1112 Documented Pass 1112 Sent Pass 1113 Contents Pass 1114 Completed Pass 1114 Investigated Pass Data Want: CaseID Q1 A1 Q2 A2 Q3 A3 1111 Claim Pass Memos Pass Procedure Fail 1112 Documented Pass Sent Pass 1113 Contents Pass 1114 Completed Pass Investigated Pass I first tried doing proc transpose but that didn't seem to get me what I needed. I then tried an array, and it looked like it was working, but we found some weird data stuff going on. Here is what I was trying below (Note that the number of questions and answers can vary on which tests were doing that given month. I tried using variables for the array and was given errors, but 50 seemed to be enough for any given test): data work.TM_Assessment_4c; set work.TM_Assessment_3c; by CaseID; array questionarray {50} $400 Q1-Q50; array answerarray {50} $400 A1-A50; if first.CaseID then i = 1; questionarray(i) = QuestionText; answerarray(i) = AnswerText; if last.CaseID then output; i+1; retain Q1-Q50; retain A1-A50; run; proc sql; create table work.TM_Assessment_5c AS select TestPeriod , TestName , CaseID , RecordPrimaryID , CaseWorkDT , AssignedOwner , ManagerName , Q1 , A1 , Q2 , A2 , Q3 , A3 , Q4 , A4 , Q5 , A5 , Q6 , A6 , Q7 , A7 , Q8 , A8 , Q9 , A9 , Q10 , A10 , Q11 , A11 , Q12 , A12 , Q13 , A13 , Q14 , A14 , Q15 , A15 , Q16 , A16 , Q17 , A17 , Q18 , A18 , Q19 , A19 , Q20 , A20 , Q21 , A21 , Q22 , A22 , Q23 , A23 , Q24 , A24 , Q25 , A25 , Q26 , A26 , Q27 , A27 , Q28 , A28 , Q29 , A29 , Q30 , A30 , Q31 , A31 , Q32 , A32 , Q33 , A33 , Q34 , A34 , Q35 , A35 , Q36 , A36 , Q37 , A37 , Q38 , A38 , Q39 , A39 , Q40 , A40 , Q41 , A41 , Q42 , A42 , Q43 , A43 , Q44 , A44 , Q45 , A45 , Q46 , A46 , Q47 , A47 , Q48 , A48 , Q49 , A49 , Q50 , A50 from work.TM_Assessment_4c order by AssignedOwner, TestPeriod, TestName, RecordPrimaryID ; quit; The output data looked like it was what we wanted at first, but the actual data was not correct. We were seeing instances where a case would have only one question and one answer, and while it was showing that in the data, it was also showing additional questions and answers on the same row that had nothing to do with it. Can anyone help me out? Thanks all.
... View more