<?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: Creating wide table to narrow table having two groups of data elements in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-wide-table-to-narrow-table-having-two-groups-of-data/m-p/726845#M225920</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/38137"&gt;@DeepakSwain&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks a lot for your quick reply. I agree with you regarding character form of date. To improve the efficiency, I will convert it to date format.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;We can actually do that when the shape is changed.&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   by id;
   array d (*) date_1-date_4;
   array w (*) weight_1-weight_4;
   do i=1 to dim(d);
      date= input(d[i],yymmdd8.);
      weight=w[i];
      output;
   end;&lt;BR /&gt;   format date yymmdd10. ;/* or format of your choosing*/
   keep id date weight;
run;&lt;/PRE&gt;</description>
    <pubDate>Tue, 16 Mar 2021 17:53:39 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-03-16T17:53:39Z</dc:date>
    <item>
      <title>Creating wide table to narrow table having two groups of data elements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-wide-table-to-narrow-table-having-two-groups-of-data/m-p/726836#M225916</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need your kind help to transpose my table having&amp;nbsp; 2 groups of data elements related to dates and weight.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
id= 101;
date_1= '20200101' ;
weight_1=51;
date_2='20200102';
weight_2=52;
date_3='20200103';
weight_3=53;
date_4='20200104';
weight_4=54;
output;
id= 102;
date_1= '20200101' ;
weight_1=61;
date_2='20200102';
weight_2=62;
date_3='20200103';
weight_3=63;
date_4=' ';
weight_4=.;
output;
id= 103;
date_1= '20200101' ;
weight_1=71;
date_2='20200102';
weight_2=72;
date_3=' ';
weight_3=. ;
date_4='20200104 ';
weight_4=74 ;
output;
run;




data want;
input id  date $ weight ;
datalines;
101 20200101 51
101 20200102 52
101 20200103 53
101 20200104 54
102 20200101 61
102 20200102 62
102 20200103 63
103 20200101 71
103 20200102 72
103 20200104 74
;
run;








&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you in advance for your kind reply.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Mar 2021 17:17:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-wide-table-to-narrow-table-having-two-groups-of-data/m-p/726836#M225916</guid>
      <dc:creator>DeepakSwain</dc:creator>
      <dc:date>2021-03-16T17:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: Creating wide table to narrow table having two groups of data elements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-wide-table-to-narrow-table-having-two-groups-of-data/m-p/726837#M225917</link>
      <description>&lt;P&gt;Why do you have "dates" as character values???&lt;/P&gt;
&lt;P&gt;One way:&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   by id;
   array d (*) date_1-date_4;
   array w (*) weight_1-weight_4;
   do i=1 to dim(d);
      date=d[i];
      weight=w[i];
      output;
   end;
   keep id date weight;
run;&lt;/PRE&gt;
&lt;P&gt;Character dates are pretty hard to work with for any manipulation and they make lousy graph axis values.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Mar 2021 17:25:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-wide-table-to-narrow-table-having-two-groups-of-data/m-p/726837#M225917</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-03-16T17:25:15Z</dc:date>
    </item>
    <item>
      <title>Re: Creating wide table to narrow table having two groups of data elements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-wide-table-to-narrow-table-having-two-groups-of-data/m-p/726840#M225919</link>
      <description>Thanks a lot for your quick reply. I agree with you regarding character form of date. To improve the efficiency, I will convert it to date format.</description>
      <pubDate>Tue, 16 Mar 2021 17:37:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-wide-table-to-narrow-table-having-two-groups-of-data/m-p/726840#M225919</guid>
      <dc:creator>DeepakSwain</dc:creator>
      <dc:date>2021-03-16T17:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: Creating wide table to narrow table having two groups of data elements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-wide-table-to-narrow-table-having-two-groups-of-data/m-p/726845#M225920</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/38137"&gt;@DeepakSwain&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks a lot for your quick reply. I agree with you regarding character form of date. To improve the efficiency, I will convert it to date format.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;We can actually do that when the shape is changed.&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   by id;
   array d (*) date_1-date_4;
   array w (*) weight_1-weight_4;
   do i=1 to dim(d);
      date= input(d[i],yymmdd8.);
      weight=w[i];
      output;
   end;&lt;BR /&gt;   format date yymmdd10. ;/* or format of your choosing*/
   keep id date weight;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Mar 2021 17:53:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-wide-table-to-narrow-table-having-two-groups-of-data/m-p/726845#M225920</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-03-16T17:53:39Z</dc:date>
    </item>
  </channel>
</rss>

