<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Transpose or Array of questions and answers by ID in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Transpose-or-Array-of-questions-and-answers-by-ID/m-p/799362#M314310</link>
    <description>&lt;P&gt;I am trying to put all questions and answers for a given ID on a single row, but am having difficulties doing so.&amp;nbsp; There are some other fields but the main ones are concerned with re-arranging the data are:CaseID QuestionText AnswerText.&amp;nbsp; The other columns are TestPeriod, TestName, RecordPrimaryID CaseWorkDT AssignedOwner ManagerName&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data I have is like this (with the additional columns but that's just extra noise at this point):&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;CaseID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;QuestionText&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AnswerText&lt;BR /&gt;1111&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Claim&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Pass&lt;BR /&gt;1111&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Memos&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Pass&lt;BR /&gt;1111&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Procedure&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Fail&lt;BR /&gt;1112&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Documented&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Pass&lt;BR /&gt;1112&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Sent&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Pass&lt;BR /&gt;1113&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;Contents&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Pass&lt;BR /&gt;1114&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Completed&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Pass&lt;BR /&gt;1114&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Investigated&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Pass&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data Want:&lt;/P&gt;&lt;P&gt;CaseID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Q1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Q2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Q3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A3&lt;BR /&gt;1111&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Claim&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Pass&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Memos&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Pass&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Procedure&amp;nbsp; &amp;nbsp;Fail&lt;BR /&gt;1112&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Documented&amp;nbsp; &amp;nbsp; Pass&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Sent&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Pass&lt;BR /&gt;1113&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Contents&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Pass&lt;BR /&gt;1114&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Completed&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Pass&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Investigated&amp;nbsp; Pass&lt;BR /&gt;&lt;BR /&gt;I first tried doing proc transpose but that didn't seem to get me what I needed.&amp;nbsp; I then tried an array, and it looked like it was working, but we found some weird data stuff going on.&lt;BR /&gt;&lt;BR /&gt;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.&amp;nbsp; I tried using variables for the array and was given errors, but 50 seemed to be enough for any given test):&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data work.TM_Assessment_4c;&lt;BR /&gt;set work.TM_Assessment_3c;&lt;BR /&gt;by CaseID;&lt;BR /&gt;array questionarray {50} $400 Q1-Q50;&lt;BR /&gt;array answerarray {50} $400 A1-A50;&lt;/P&gt;&lt;P&gt;if first.CaseID then&lt;BR /&gt;i = 1;&lt;BR /&gt;questionarray(i) = QuestionText;&lt;BR /&gt;answerarray(i) = AnswerText;&lt;/P&gt;&lt;P&gt;if last.CaseID then&lt;BR /&gt;output;&lt;BR /&gt;i+1;&lt;BR /&gt;retain Q1-Q50;&lt;BR /&gt;retain A1-A50;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table work.TM_Assessment_5c AS&lt;BR /&gt;select TestPeriod&lt;BR /&gt;, TestName&lt;BR /&gt;, CaseID&lt;BR /&gt;, RecordPrimaryID&lt;BR /&gt;, CaseWorkDT&lt;BR /&gt;, AssignedOwner&lt;BR /&gt;, ManagerName&lt;BR /&gt;, Q1&lt;BR /&gt;, A1&lt;BR /&gt;, Q2&lt;BR /&gt;, A2&lt;BR /&gt;, Q3&lt;BR /&gt;, A3&lt;BR /&gt;, Q4&lt;BR /&gt;, A4&lt;BR /&gt;, Q5&lt;BR /&gt;, A5&lt;BR /&gt;, Q6&lt;BR /&gt;, A6&lt;BR /&gt;, Q7&lt;BR /&gt;, A7&lt;BR /&gt;, Q8&lt;BR /&gt;, A8&lt;BR /&gt;, Q9&lt;BR /&gt;, A9&lt;BR /&gt;, Q10&lt;BR /&gt;, A10&lt;BR /&gt;, Q11&lt;BR /&gt;, A11&lt;BR /&gt;, Q12&lt;BR /&gt;, A12&lt;BR /&gt;, Q13&lt;BR /&gt;, A13&lt;BR /&gt;, Q14&lt;BR /&gt;, A14&lt;BR /&gt;, Q15&lt;BR /&gt;, A15&lt;BR /&gt;, Q16&lt;BR /&gt;, A16&lt;BR /&gt;, Q17&lt;BR /&gt;, A17&lt;BR /&gt;, Q18&lt;BR /&gt;, A18&lt;BR /&gt;, Q19&lt;BR /&gt;, A19&lt;BR /&gt;, Q20&lt;BR /&gt;, A20&lt;BR /&gt;, Q21&lt;BR /&gt;, A21&lt;BR /&gt;, Q22&lt;BR /&gt;, A22&lt;BR /&gt;, Q23&lt;BR /&gt;, A23&lt;BR /&gt;, Q24&lt;BR /&gt;, A24&lt;BR /&gt;, Q25&lt;BR /&gt;, A25&lt;BR /&gt;, Q26&lt;BR /&gt;, A26&lt;BR /&gt;, Q27&lt;BR /&gt;, A27&lt;BR /&gt;, Q28&lt;BR /&gt;, A28&lt;BR /&gt;, Q29&lt;BR /&gt;, A29&lt;BR /&gt;, Q30&lt;BR /&gt;, A30&lt;BR /&gt;, Q31&lt;BR /&gt;, A31&lt;BR /&gt;, Q32&lt;BR /&gt;, A32&lt;BR /&gt;, Q33&lt;BR /&gt;, A33&lt;BR /&gt;, Q34&lt;BR /&gt;, A34&lt;BR /&gt;, Q35&lt;BR /&gt;, A35&lt;BR /&gt;, Q36&lt;BR /&gt;, A36&lt;BR /&gt;, Q37&lt;BR /&gt;, A37&lt;BR /&gt;, Q38&lt;BR /&gt;, A38&lt;BR /&gt;, Q39&lt;BR /&gt;, A39&lt;BR /&gt;, Q40&lt;BR /&gt;, A40&lt;BR /&gt;, Q41&lt;BR /&gt;, A41&lt;BR /&gt;, Q42&lt;BR /&gt;, A42&lt;BR /&gt;, Q43&lt;BR /&gt;, A43&lt;BR /&gt;, Q44&lt;BR /&gt;, A44&lt;BR /&gt;, Q45&lt;BR /&gt;, A45&lt;BR /&gt;, Q46&lt;BR /&gt;, A46&lt;BR /&gt;, Q47&lt;BR /&gt;, A47&lt;BR /&gt;, Q48&lt;BR /&gt;, A48&lt;BR /&gt;, Q49&lt;BR /&gt;, A49&lt;BR /&gt;, Q50&lt;BR /&gt;, A50&lt;BR /&gt;from work.TM_Assessment_4c&lt;BR /&gt;order by AssignedOwner, TestPeriod, TestName, RecordPrimaryID&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;The output data looked like it was what we wanted at first, but the actual data was not correct.&amp;nbsp; 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.&lt;BR /&gt;&lt;BR /&gt;Can anyone help me out?&lt;BR /&gt;&lt;BR /&gt;Thanks all.&lt;/P&gt;</description>
    <pubDate>Tue, 01 Mar 2022 16:09:44 GMT</pubDate>
    <dc:creator>Maldra</dc:creator>
    <dc:date>2022-03-01T16:09:44Z</dc:date>
    <item>
      <title>Transpose or Array of questions and answers by ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-or-Array-of-questions-and-answers-by-ID/m-p/799362#M314310</link>
      <description>&lt;P&gt;I am trying to put all questions and answers for a given ID on a single row, but am having difficulties doing so.&amp;nbsp; There are some other fields but the main ones are concerned with re-arranging the data are:CaseID QuestionText AnswerText.&amp;nbsp; The other columns are TestPeriod, TestName, RecordPrimaryID CaseWorkDT AssignedOwner ManagerName&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data I have is like this (with the additional columns but that's just extra noise at this point):&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;CaseID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;QuestionText&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AnswerText&lt;BR /&gt;1111&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Claim&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Pass&lt;BR /&gt;1111&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Memos&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Pass&lt;BR /&gt;1111&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Procedure&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Fail&lt;BR /&gt;1112&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Documented&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Pass&lt;BR /&gt;1112&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Sent&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Pass&lt;BR /&gt;1113&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;Contents&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Pass&lt;BR /&gt;1114&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Completed&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Pass&lt;BR /&gt;1114&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Investigated&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Pass&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data Want:&lt;/P&gt;&lt;P&gt;CaseID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Q1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Q2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Q3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A3&lt;BR /&gt;1111&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Claim&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Pass&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Memos&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Pass&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Procedure&amp;nbsp; &amp;nbsp;Fail&lt;BR /&gt;1112&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Documented&amp;nbsp; &amp;nbsp; Pass&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Sent&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Pass&lt;BR /&gt;1113&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Contents&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Pass&lt;BR /&gt;1114&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Completed&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Pass&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Investigated&amp;nbsp; Pass&lt;BR /&gt;&lt;BR /&gt;I first tried doing proc transpose but that didn't seem to get me what I needed.&amp;nbsp; I then tried an array, and it looked like it was working, but we found some weird data stuff going on.&lt;BR /&gt;&lt;BR /&gt;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.&amp;nbsp; I tried using variables for the array and was given errors, but 50 seemed to be enough for any given test):&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data work.TM_Assessment_4c;&lt;BR /&gt;set work.TM_Assessment_3c;&lt;BR /&gt;by CaseID;&lt;BR /&gt;array questionarray {50} $400 Q1-Q50;&lt;BR /&gt;array answerarray {50} $400 A1-A50;&lt;/P&gt;&lt;P&gt;if first.CaseID then&lt;BR /&gt;i = 1;&lt;BR /&gt;questionarray(i) = QuestionText;&lt;BR /&gt;answerarray(i) = AnswerText;&lt;/P&gt;&lt;P&gt;if last.CaseID then&lt;BR /&gt;output;&lt;BR /&gt;i+1;&lt;BR /&gt;retain Q1-Q50;&lt;BR /&gt;retain A1-A50;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table work.TM_Assessment_5c AS&lt;BR /&gt;select TestPeriod&lt;BR /&gt;, TestName&lt;BR /&gt;, CaseID&lt;BR /&gt;, RecordPrimaryID&lt;BR /&gt;, CaseWorkDT&lt;BR /&gt;, AssignedOwner&lt;BR /&gt;, ManagerName&lt;BR /&gt;, Q1&lt;BR /&gt;, A1&lt;BR /&gt;, Q2&lt;BR /&gt;, A2&lt;BR /&gt;, Q3&lt;BR /&gt;, A3&lt;BR /&gt;, Q4&lt;BR /&gt;, A4&lt;BR /&gt;, Q5&lt;BR /&gt;, A5&lt;BR /&gt;, Q6&lt;BR /&gt;, A6&lt;BR /&gt;, Q7&lt;BR /&gt;, A7&lt;BR /&gt;, Q8&lt;BR /&gt;, A8&lt;BR /&gt;, Q9&lt;BR /&gt;, A9&lt;BR /&gt;, Q10&lt;BR /&gt;, A10&lt;BR /&gt;, Q11&lt;BR /&gt;, A11&lt;BR /&gt;, Q12&lt;BR /&gt;, A12&lt;BR /&gt;, Q13&lt;BR /&gt;, A13&lt;BR /&gt;, Q14&lt;BR /&gt;, A14&lt;BR /&gt;, Q15&lt;BR /&gt;, A15&lt;BR /&gt;, Q16&lt;BR /&gt;, A16&lt;BR /&gt;, Q17&lt;BR /&gt;, A17&lt;BR /&gt;, Q18&lt;BR /&gt;, A18&lt;BR /&gt;, Q19&lt;BR /&gt;, A19&lt;BR /&gt;, Q20&lt;BR /&gt;, A20&lt;BR /&gt;, Q21&lt;BR /&gt;, A21&lt;BR /&gt;, Q22&lt;BR /&gt;, A22&lt;BR /&gt;, Q23&lt;BR /&gt;, A23&lt;BR /&gt;, Q24&lt;BR /&gt;, A24&lt;BR /&gt;, Q25&lt;BR /&gt;, A25&lt;BR /&gt;, Q26&lt;BR /&gt;, A26&lt;BR /&gt;, Q27&lt;BR /&gt;, A27&lt;BR /&gt;, Q28&lt;BR /&gt;, A28&lt;BR /&gt;, Q29&lt;BR /&gt;, A29&lt;BR /&gt;, Q30&lt;BR /&gt;, A30&lt;BR /&gt;, Q31&lt;BR /&gt;, A31&lt;BR /&gt;, Q32&lt;BR /&gt;, A32&lt;BR /&gt;, Q33&lt;BR /&gt;, A33&lt;BR /&gt;, Q34&lt;BR /&gt;, A34&lt;BR /&gt;, Q35&lt;BR /&gt;, A35&lt;BR /&gt;, Q36&lt;BR /&gt;, A36&lt;BR /&gt;, Q37&lt;BR /&gt;, A37&lt;BR /&gt;, Q38&lt;BR /&gt;, A38&lt;BR /&gt;, Q39&lt;BR /&gt;, A39&lt;BR /&gt;, Q40&lt;BR /&gt;, A40&lt;BR /&gt;, Q41&lt;BR /&gt;, A41&lt;BR /&gt;, Q42&lt;BR /&gt;, A42&lt;BR /&gt;, Q43&lt;BR /&gt;, A43&lt;BR /&gt;, Q44&lt;BR /&gt;, A44&lt;BR /&gt;, Q45&lt;BR /&gt;, A45&lt;BR /&gt;, Q46&lt;BR /&gt;, A46&lt;BR /&gt;, Q47&lt;BR /&gt;, A47&lt;BR /&gt;, Q48&lt;BR /&gt;, A48&lt;BR /&gt;, Q49&lt;BR /&gt;, A49&lt;BR /&gt;, Q50&lt;BR /&gt;, A50&lt;BR /&gt;from work.TM_Assessment_4c&lt;BR /&gt;order by AssignedOwner, TestPeriod, TestName, RecordPrimaryID&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;The output data looked like it was what we wanted at first, but the actual data was not correct.&amp;nbsp; 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.&lt;BR /&gt;&lt;BR /&gt;Can anyone help me out?&lt;BR /&gt;&lt;BR /&gt;Thanks all.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2022 16:09:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-or-Array-of-questions-and-answers-by-ID/m-p/799362#M314310</guid>
      <dc:creator>Maldra</dc:creator>
      <dc:date>2022-03-01T16:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose or Array of questions and answers by ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-or-Array-of-questions-and-answers-by-ID/m-p/799366#M314314</link>
      <description>Quick question - why? I usually spend my time getting my survey data into the format shown to make reporting and analysis easier.</description>
      <pubDate>Tue, 01 Mar 2022 16:24:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-or-Array-of-questions-and-answers-by-ID/m-p/799366#M314314</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-03-01T16:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose or Array of questions and answers by ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-or-Array-of-questions-and-answers-by-ID/m-p/799371#M314318</link>
      <description>&lt;P&gt;Personally I find your "want" structure to be subject to many problems. I can see a strong possibility the the Q value of "Claim" could end up in many different variables is just processing in order.&lt;/P&gt;
&lt;P&gt;I suggest something like this may be more appropriate where each "question text" becomes the variable name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
 input id $ Activity :$15. Status :$6.;
datalines;
1111  Claim   Pass
1111  Memos  Pass
1111  Procedure   Fail
1112  Documented Pass
1112  Sent    Pass
1113  Contents   Pass
1114  Completed  Pass
1114  Investigated  Pass
;


proc transpose data=example out=trans (drop=_name_);
   by id;
   var status;
   id Activity;
run;&lt;/PRE&gt;
&lt;P&gt;Note providing some data in the form of a data step that you can run to duplicate the results and posted into a text box.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2022 16:29:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-or-Array-of-questions-and-answers-by-ID/m-p/799371#M314318</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-01T16:29:23Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose or Array of questions and answers by ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-or-Array-of-questions-and-answers-by-ID/m-p/799375#M314321</link>
      <description>That is what the stakeholder requested. I'm not sure on the reasoning.</description>
      <pubDate>Tue, 01 Mar 2022 16:33:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-or-Array-of-questions-and-answers-by-ID/m-p/799375#M314321</guid>
      <dc:creator>Maldra</dc:creator>
      <dc:date>2022-03-01T16:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose or Array of questions and answers by ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-or-Array-of-questions-and-answers-by-ID/m-p/799380#M314325</link>
      <description>Unfortunately that won't work really since there are thousands of different questions since there are thousands of test with different questions. It was just dummy data that I provided; the actual questions are long sentences. I may just have to go to them with the "have" data format if I can't get the "want" format.</description>
      <pubDate>Tue, 01 Mar 2022 16:41:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-or-Array-of-questions-and-answers-by-ID/m-p/799380#M314325</guid>
      <dc:creator>Maldra</dc:creator>
      <dc:date>2022-03-01T16:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose or Array of questions and answers by ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-or-Array-of-questions-and-answers-by-ID/m-p/799387#M314330</link>
      <description>&lt;P&gt;Could you explain the logic of how the data is stored?&lt;/P&gt;
&lt;P&gt;What I have observed is Q1 is always the first.caseid which you will save as QuestionText and A1 as the Answertext&lt;/P&gt;
&lt;P&gt;Then you remove the first.caseid record, in the next iteration Q2 is the first.caseid.&lt;/P&gt;
&lt;P&gt;and so on for Q3&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Will this iterative process work with your survey data structre?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2022 16:58:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-or-Array-of-questions-and-answers-by-ID/m-p/799387#M314330</guid>
      <dc:creator>ghosh</dc:creator>
      <dc:date>2022-03-01T16:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose or Array of questions and answers by ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-or-Array-of-questions-and-answers-by-ID/m-p/799388#M314331</link>
      <description>&lt;P&gt;Before you can make the data you need to answer this question:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you want the same question/answer pair to always end up in the same pair of variables across the cases?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example do you want CLAIM to always go into Q1?&amp;nbsp; And if a case does not have the CLAIM quesiton that it has missing values of Q1?&amp;nbsp; Or perhaps missing values for A1 but Q1 still says CLAIM?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In that case you need to first map the Question text to the variable number.&amp;nbsp; Do you have a full set of possible values?&amp;nbsp; Or do you want to just use the set of questions in the current file?&amp;nbsp; If the later will you ever get any other files of this type?&amp;nbsp; Do they need to be mapped into the same variables?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or is it ok that for the first case Q1 is CLAIM and for the second case Q1 is DOCUMENTED?&lt;/P&gt;
&lt;P&gt;To just numbers them sequentially within each CASE is the easiest.&lt;/P&gt;
&lt;P&gt;I like to use PROC SUMMARY.&lt;/P&gt;
&lt;P&gt;First you need to know the maximum number of questions any single CASE could have.&lt;/P&gt;
&lt;P&gt;Let's call that number N and stick it into a macro variable named N.&amp;nbsp; For your dummy data N is 3.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input CaseID :$10. QuestionText :$40. AnswerText :$10.;
cards;
1111  Claim             Pass
1111  Memos             Pass
1111  Procedure         Fail
1112  Documented        Pass
1112  Sent              Pass
1113  Contents          Pass
1114  Completed         Pass
1114  Investigated      Pass
;

%let N=3;
proc summary data=have nway ;
  by caseid;
  output out=want(drop=_type_) idgroup (out[&amp;amp;n] (questiontext answertext)=);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;       Case              Question      Question        Question     Answer    Answer    Answer
Obs     ID     _FREQ_    Text_1        Text_2           Text_3      Text_1    Text_2    Text_3

 1     1111       3      Claim         Memos           Procedure     Pass      Pass      Fail
 2     1112       2      Documented    Sent                          Pass      Pass
 3     1113       1      Contents                                    Pass
 4     1114       2      Completed     Investigated                  Pass      Pass
&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Mar 2022 16:59:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-or-Array-of-questions-and-answers-by-ID/m-p/799388#M314331</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-01T16:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose or Array of questions and answers by ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-or-Array-of-questions-and-answers-by-ID/m-p/799394#M314336</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/418445"&gt;@Maldra&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Unfortunately that won't work really since there are thousands of different questions since there are thousands of test with different questions. It was just dummy data that I provided; the actual questions are long sentences. I may just have to go to them with the "have" data format if I can't get the "want" format.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Possibly even more reason not to make a data set in that format.&lt;/P&gt;
&lt;P&gt;"Long sentences" might typically be a Label for a specific variable.&lt;/P&gt;
&lt;P&gt;I would take a document, you do have one don't you, with all the "long sentence" values and make a data set or informat that links each specific sentence to a variable name to a specific order number. Then you have something that could add "Q1" or "A1" consistently.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;proc format;
invalue text2order (upcase)

'CLAIM'        =  1 
'MEMOS'        =  2
'PROCEDURE'    =  3
'DOCUMENTED'   =  4
'SENT'         =  5
'CONTENTS'     =  6
'COMPLETED'    =  7
'INVESTIGATED' =  8
;
run;

data example;
  input CaseID :$10. QuestionText :$40. AnswerText :$10.;
datalines;
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;
   set example;
   array q(8) $ 40;
   array a(8) $ 10;
   retain q: a:;
   by caseid;
   if first.caseid then call missing(of q(*), of a(*));
   q[input(questiontext,text2order.)]= questiontext;
   a[input(questiontext,text2order.)]= AnswerText;
   if last.caseid;
   keep caseid q1-q8 a1-a8;
run;


&lt;/PRE&gt;
&lt;P&gt;If you have any form of electronic document with the "questions" you should be able to create the invalue using Proc Format and a CNTLIN data set.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2022 17:24:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-or-Array-of-questions-and-answers-by-ID/m-p/799394#M314336</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-01T17:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose or Array of questions and answers by ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-or-Array-of-questions-and-answers-by-ID/m-p/799420#M314349</link>
      <description>Each test has a maximum of about 45 questions, but there are a lot of different tests with a lot of different questions. If it were that way, there would be thousands of columns, which is not what they were looking for. They just wanted all of the questions and answers one after the other in a single row.</description>
      <pubDate>Tue, 01 Mar 2022 19:01:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-or-Array-of-questions-and-answers-by-ID/m-p/799420#M314349</guid>
      <dc:creator>Maldra</dc:creator>
      <dc:date>2022-03-01T19:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose or Array of questions and answers by ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-or-Array-of-questions-and-answers-by-ID/m-p/799425#M314353</link>
      <description>Looks like Tom's answer will work for you then &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Tue, 01 Mar 2022 19:10:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-or-Array-of-questions-and-answers-by-ID/m-p/799425#M314353</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-03-01T19:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose or Array of questions and answers by ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-or-Array-of-questions-and-answers-by-ID/m-p/799464#M314372</link>
      <description>&lt;P&gt;Nothing to identify what the source of the questions is???&lt;/P&gt;
&lt;P&gt;If there were such a field then this is partially defensible but I bet you are going to deal with issues of dates and numeric values converting to text somewhere along the line.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2022 23:00:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-or-Array-of-questions-and-answers-by-ID/m-p/799464#M314372</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-01T23:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose or Array of questions and answers by ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-or-Array-of-questions-and-answers-by-ID/m-p/800950#M315169</link>
      <description>&lt;P&gt;After talking to the stakeholders some more, the reason they want it in this format is so they can enter it into a system, and that is how it takes the data.&amp;nbsp; The solution of having gaps also wouldn't work.&amp;nbsp; It needs to look like my original post.&amp;nbsp; Is this something SAS is able to do?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 22:17:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-or-Array-of-questions-and-answers-by-ID/m-p/800950#M315169</guid>
      <dc:creator>Maldra</dc:creator>
      <dc:date>2022-03-08T22:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose or Array of questions and answers by ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-or-Array-of-questions-and-answers-by-ID/m-p/800957#M315174</link>
      <description>&lt;P&gt;You have a couple of answer to produce what you asked for.&lt;/P&gt;
&lt;P&gt;Please explain it what way they are not what you need?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If they are entering into a "system" what type of file do they need?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 23:13:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-or-Array-of-questions-and-answers-by-ID/m-p/800957#M315174</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-08T23:13:07Z</dc:date>
    </item>
  </channel>
</rss>

