<?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 Re: Table transformation - multiple values within single field in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Table-transformation-multiple-values-within-single-field/m-p/835754#M330427</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'll be glad to reply to your question and explain this:&lt;/P&gt;
&lt;P&gt;First, I agree with you, I am quite aware that date presented in Table 2 cannot be of any use for further data analysis neither they give additional information compared to Table 1, BUT I usually need to give a summary to clinical data mangers and clinical coordinators and for them Table 1 data can be very "bulky" and difficult to handle and here is why: For example, imagine that we have patients Pat1, Pat2, Pat3..., and that each of them has Visit01 - Visit10, and within each visit exactly the same questions they need to answer with simple Yes or No, and that data managers/clinical coordinators want to see during what visits they answered Yes and during what visits they answered No (maybe they are supposed to answer all visits in certain way but, got some reason, clinical coordinators mistakenly entered No... who knows... not to go into details). So data managers/clinical coordinators, in first table, they would have to deal with maybe 300 entries (lets say 30 patients each with 10 visits) and they may find that very cumbersome, while in the Table 2 they are going to have 30 patients where they are going to be able to easily spot any patient that has the same question answered or recorded differently then expected. This is simplified explanation, the number of patients can be much higher, as well as number of questions... but I didn't want to go into too many details and make my original question even more complicated as this was all I wanted to find out, then I'll go over it&amp;nbsp; and apply the method further. Please let me know if you have any additional question or if my question became to messy. Thank you so much for your time. &lt;/P&gt;
&lt;P&gt;All the best!&lt;/P&gt;</description>
    <pubDate>Thu, 29 Sep 2022 02:28:42 GMT</pubDate>
    <dc:creator>Batta</dc:creator>
    <dc:date>2022-09-29T02:28:42Z</dc:date>
    <item>
      <title>Table transformation - multiple values within single field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Table-transformation-multiple-values-within-single-field/m-p/835710#M330415</link>
      <description>&lt;P&gt;Hello SAS experts,&lt;/P&gt;
&lt;P&gt;I hope you can help me with this: I need to transfer Table 1 in a way shown in Table 2. How can I do this using either proc sql or any other way?&lt;/P&gt;
&lt;P&gt;Thank you very much,&lt;/P&gt;
&lt;P&gt;Batta&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Table 1&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 144pt;" border="0" width="191px" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="63.1406px" height="20" class="xl64" style="height: 15.0pt; width: 48pt;"&gt;ID&lt;/TD&gt;
&lt;TD width="63.9062px" class="xl64" style="border-left: none; width: 48pt;"&gt;VisitNo&lt;/TD&gt;
&lt;TD width="63.9531px" class="xl64" style="border-left: none; width: 48pt;"&gt;OBJNo&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="63.1406px" height="20" class="xl63" style="height: 15.0pt; border-top: none;"&gt;ID1&lt;/TD&gt;
&lt;TD width="63.9062px" class="xl63" style="border-top: none; border-left: none;"&gt;V1&lt;/TD&gt;
&lt;TD width="63.9531px" class="xl63" style="border-top: none; border-left: none;"&gt;OBJ1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="63.1406px" height="20" class="xl63" style="height: 15.0pt; border-top: none;"&gt;ID1&lt;/TD&gt;
&lt;TD width="63.9062px" class="xl63" style="border-top: none; border-left: none;"&gt;V2&lt;/TD&gt;
&lt;TD width="63.9531px" class="xl63" style="border-top: none; border-left: none;"&gt;OBJ1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="63.1406px" height="20" class="xl63" style="height: 15.0pt; border-top: none;"&gt;ID1&lt;/TD&gt;
&lt;TD width="63.9062px" class="xl63" style="border-top: none; border-left: none;"&gt;V3&lt;/TD&gt;
&lt;TD width="63.9531px" class="xl63" style="border-top: none; border-left: none;"&gt;OBJ1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="63.1406px" height="20" class="xl63" style="height: 15.0pt; border-top: none;"&gt;ID2&lt;/TD&gt;
&lt;TD width="63.9062px" class="xl63" style="border-top: none; border-left: none;"&gt;V1&lt;/TD&gt;
&lt;TD width="63.9531px" class="xl63" style="border-top: none; border-left: none;"&gt;OBJ2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="63.1406px" height="20" class="xl63" style="height: 15.0pt; border-top: none;"&gt;ID2&lt;/TD&gt;
&lt;TD width="63.9062px" class="xl63" style="border-top: none; border-left: none;"&gt;V2&lt;/TD&gt;
&lt;TD width="63.9531px" class="xl63" style="border-top: none; border-left: none;"&gt;OBJ2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="63.1406px" height="20" class="xl63" style="height: 15.0pt; border-top: none;"&gt;ID3&lt;/TD&gt;
&lt;TD width="63.9062px" class="xl63" style="border-top: none; border-left: none;"&gt;V1&lt;/TD&gt;
&lt;TD width="63.9531px" class="xl63" style="border-top: none; border-left: none;"&gt;OBJ3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="63.1406px" height="20" class="xl63" style="height: 15.0pt; border-top: none;"&gt;ID3&lt;/TD&gt;
&lt;TD width="63.9062px" class="xl63" style="border-top: none; border-left: none;"&gt;V2&lt;/TD&gt;
&lt;TD width="63.9531px" class="xl63" style="border-top: none; border-left: none;"&gt;OBJ3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="63.1406px" height="20" class="xl63" style="height: 15.0pt; border-top: none;"&gt;ID3&lt;/TD&gt;
&lt;TD width="63.9062px" class="xl63" style="border-top: none; border-left: none;"&gt;V3&lt;/TD&gt;
&lt;TD width="63.9531px" class="xl63" style="border-top: none; border-left: none;"&gt;OBJ3&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Table 2&lt;/P&gt;
&lt;TABLE class=" lia-align-left" style="height: 174px; width: 400px;" width="400"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="56.5156px" height="30px"&gt;ID&lt;/TD&gt;
&lt;TD width="77.7188px" height="30px"&gt;VisitNo&lt;/TD&gt;
&lt;TD width="77.7656px" height="30px"&gt;OBJNo&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="56.5156px" height="57px"&gt;ID1&lt;/TD&gt;
&lt;TD width="77.7188px" height="57px"&gt;V1, V2, V3&lt;/TD&gt;
&lt;TD width="77.7656px" height="57px"&gt;OBJ1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="56.5156px" height="30px"&gt;ID2&lt;/TD&gt;
&lt;TD width="77.7188px" height="30px"&gt;V1, V2&lt;/TD&gt;
&lt;TD width="77.7656px" height="30px"&gt;OBJ2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="56.5156px" height="57px"&gt;ID3&lt;/TD&gt;
&lt;TD width="77.7188px" height="57px"&gt;V1, V2, V3&lt;/TD&gt;
&lt;TD width="77.7656px" height="57px"&gt;OBJ3&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2022 21:02:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Table-transformation-multiple-values-within-single-field/m-p/835710#M330415</guid>
      <dc:creator>Batta</dc:creator>
      <dc:date>2022-09-28T21:02:40Z</dc:date>
    </item>
    <item>
      <title>Re: Table transformation - multiple values within single field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Table-transformation-multiple-values-within-single-field/m-p/835711#M330416</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID $ VisitNo $ OBJNo $;
datalines;
ID1 V1 OBJ1 
ID1 V2 OBJ1 
ID1 V3 OBJ1 
ID2 V1 OBJ2 
ID2 V2 OBJ2 
ID3 V1 OBJ3 
ID3 V2 OBJ3 
ID3 V3 OBJ3 
;

data want;
   set have(rename = VisitNo = v);
   by ID;
   length VisitNo $200;

   if first.ID then VisitNo = '';

   VisitNo = catx(', ', VisitNo, v);

   if last.ID;
   
   retain VisitNo;
   drop v;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Sep 2022 21:17:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Table-transformation-multiple-values-within-single-field/m-p/835711#M330416</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-09-28T21:17:02Z</dc:date>
    </item>
    <item>
      <title>Re: Table transformation - multiple values within single field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Table-transformation-multiple-values-within-single-field/m-p/835720#M330418</link>
      <description>&lt;P&gt;Please tell us what you can do with that new data set structure that you can't with the existing one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We get a similar request nearly weekly and seldom get an answer to this.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2022 21:44:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Table-transformation-multiple-values-within-single-field/m-p/835720#M330418</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-09-28T21:44:00Z</dc:date>
    </item>
    <item>
      <title>Re: Table transformation - multiple values within single field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Table-transformation-multiple-values-within-single-field/m-p/835754#M330427</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'll be glad to reply to your question and explain this:&lt;/P&gt;
&lt;P&gt;First, I agree with you, I am quite aware that date presented in Table 2 cannot be of any use for further data analysis neither they give additional information compared to Table 1, BUT I usually need to give a summary to clinical data mangers and clinical coordinators and for them Table 1 data can be very "bulky" and difficult to handle and here is why: For example, imagine that we have patients Pat1, Pat2, Pat3..., and that each of them has Visit01 - Visit10, and within each visit exactly the same questions they need to answer with simple Yes or No, and that data managers/clinical coordinators want to see during what visits they answered Yes and during what visits they answered No (maybe they are supposed to answer all visits in certain way but, got some reason, clinical coordinators mistakenly entered No... who knows... not to go into details). So data managers/clinical coordinators, in first table, they would have to deal with maybe 300 entries (lets say 30 patients each with 10 visits) and they may find that very cumbersome, while in the Table 2 they are going to have 30 patients where they are going to be able to easily spot any patient that has the same question answered or recorded differently then expected. This is simplified explanation, the number of patients can be much higher, as well as number of questions... but I didn't want to go into too many details and make my original question even more complicated as this was all I wanted to find out, then I'll go over it&amp;nbsp; and apply the method further. Please let me know if you have any additional question or if my question became to messy. Thank you so much for your time. &lt;/P&gt;
&lt;P&gt;All the best!&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 02:28:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Table-transformation-multiple-values-within-single-field/m-p/835754#M330427</guid>
      <dc:creator>Batta</dc:creator>
      <dc:date>2022-09-29T02:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: Table transformation - multiple values within single field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Table-transformation-multiple-values-within-single-field/m-p/835755#M330428</link>
      <description>&lt;P&gt;Thank you very much for your time Sir,&lt;/P&gt;
&lt;P&gt;I'll check this as soon I can. I hope this will work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards!&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 02:30:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Table-transformation-multiple-values-within-single-field/m-p/835755#M330428</guid>
      <dc:creator>Batta</dc:creator>
      <dc:date>2022-09-29T02:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: Table transformation - multiple values within single field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Table-transformation-multiple-values-within-single-field/m-p/835757#M330430</link>
      <description>&lt;P&gt;You need to use BY group processing.&amp;nbsp; You will need a NEW variable. Make to make it long enough the hold the new strings.&amp;nbsp; You can also rename if you want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input ID $ VisitNo $ OBJNo $;
cards;
ID1 V1 OBJ1
ID1 V2 OBJ1
ID1 V3 OBJ1
ID2 V1 OBJ2
ID2 V2 OBJ2
ID3 V1 OBJ3
ID3 V2 OBJ3
ID3 V3 OBJ3 
;

data want;
do until(last.objno);
  set have;
  by id objno;
  length new $100;
  new=catx(',',new,visitno);
end;
  drop visitno;
  rename new=visitno;
run;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs    ID     OBJNo    visitno

 1     ID1    OBJ1     V1,V2,V3
 2     ID2    OBJ2     V1,V2
 3     ID3    OBJ3     V1,V2,V3

&lt;/PRE&gt;
&lt;P&gt;You might want to just give them a report:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=have;
 column id (objno n),visitno;
 define id / group;
 define visitno/across ' ';
 define objno / display ' ';
 define n / noprint;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;PRE&gt;  ID        V1        V2        V3
  ID1       OBJ1      OBJ1      OBJ1
  ID2       OBJ2      OBJ2
  ID3       OBJ3      OBJ3      OBJ3
&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Sep 2022 02:48:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Table-transformation-multiple-values-within-single-field/m-p/835757#M330430</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-09-29T02:48:41Z</dc:date>
    </item>
    <item>
      <title>Re: Table transformation - multiple values within single field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Table-transformation-multiple-values-within-single-field/m-p/835826#M330467</link>
      <description>&lt;P&gt;Thank you very much.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Far more than I expected! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Batta&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 12:32:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Table-transformation-multiple-values-within-single-field/m-p/835826#M330467</guid>
      <dc:creator>Batta</dc:creator>
      <dc:date>2022-09-29T12:32:31Z</dc:date>
    </item>
    <item>
      <title>Re: Table transformation - multiple values within single field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Table-transformation-multiple-values-within-single-field/m-p/835845#M330471</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/361111"&gt;@Batta&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'll be glad to reply to your question and explain this:&lt;/P&gt;
&lt;P&gt;First, I agree with you, I am quite aware that date presented in Table 2 cannot be of any use for further data analysis neither they give additional information compared to Table 1, BUT I usually need to give a summary to clinical data mangers and clinical coordinators and for them Table 1 data can be very "bulky" and difficult to handle and here is why: For example, imagine that we have patients Pat1, Pat2, Pat3..., and that each of them has Visit01 - Visit10, and within each visit exactly the same questions they need to answer with simple Yes or No, and that data managers/clinical coordinators want to see during what visits they answered Yes and during what visits they answered No (maybe they are supposed to answer all visits in certain way but, got some reason, clinical coordinators mistakenly entered No... who knows... not to go into details). So data managers/clinical coordinators, in first table, they would have to deal with maybe 300 entries (lets say 30 patients each with 10 visits) and they may find that very cumbersome, while in the Table 2 they are going to have 30 patients where they are going to be able to easily spot any patient that has the same question answered or recorded differently then expected. This is simplified explanation, the number of patients can be much higher, as well as number of questions... but I didn't want to go into too many details and make my original question even more complicated as this was all I wanted to find out, then I'll go over it&amp;nbsp; and apply the method further. Please let me know if you have any additional question or if my question became to messy. Thank you so much for your time.&lt;/P&gt;
&lt;P&gt;All the best!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Which describes a need for a report.&lt;/P&gt;
&lt;P&gt;Possibly:&lt;/P&gt;
&lt;PRE&gt;data have;
  input ID $ VisitNo $ OBJNo $;
cards;
ID1 V1 OBJ1
ID1 V2 OBJ1
ID1 V3 OBJ1
ID2 V1 OBJ2
ID2 V2 OBJ2
ID3 V1 OBJ3
ID3 V2 OBJ3
ID3 V3 OBJ3 
;

proc report data=have;
   columns id visitno objno;
   define id/ group;
   define visitno / across;
   define objno/group;
run;&lt;/PRE&gt;
&lt;P&gt;I submit that this report is much easier to identify similarity/difference of visit values that a comma separated list. Especially by the time you get to some "patients" with 15 or more visits.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 14:12:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Table-transformation-multiple-values-within-single-field/m-p/835845#M330471</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-09-29T14:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: Table transformation - multiple values within single field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Table-transformation-multiple-values-within-single-field/m-p/835848#M330473</link>
      <description>This kind or report would work too! &lt;BR /&gt;Thank you!&lt;BR /&gt;Kind regards.</description>
      <pubDate>Thu, 29 Sep 2022 14:19:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Table-transformation-multiple-values-within-single-field/m-p/835848#M330473</guid>
      <dc:creator>Batta</dc:creator>
      <dc:date>2022-09-29T14:19:14Z</dc:date>
    </item>
  </channel>
</rss>

