<?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: Split single colum data into multiple column in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Split-single-colum-data-into-multiple-column/m-p/667604#M23044</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    by name;
    array regdt{5} reg_date1-reg_date5;
    array testdt{5} test_date1-test_date5;
    
    retain reg_date: test_date:;
    format reg_date: test_date: mmddyys10.;
    
    if first.name then counter=1;
    regdt{counter}=reg_dates;
    testdt{counter}=test_dates;
    if last.name then do;
        output;
        /* Added these call missing steps */
        call missing(of reg_date1-reg_date5);
        call missing (of test_date1-test_date5);
        end;
    
    counter+1;
    drop reg_dates test_dates counter;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ketpt42_0-1594172496285.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/46988iB0502FB447FAF389/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ketpt42_0-1594172496285.png" alt="ketpt42_0-1594172496285.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 08 Jul 2020 01:41:55 GMT</pubDate>
    <dc:creator>ketpt42</dc:creator>
    <dc:date>2020-07-08T01:41:55Z</dc:date>
    <item>
      <title>Split single colum data into multiple column</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-single-colum-data-into-multiple-column/m-p/667601#M23043</link>
      <description>&lt;P&gt;I have follwoing dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;infile datalines dsd dlm=',' ;&lt;BR /&gt;input name :$3. id :$3. reg_dates :MMDDYY10. test_dates :MMDDYY10.;&lt;BR /&gt;datalines;&lt;BR /&gt;abc,010,01/10/2017,01/20/2017&lt;BR /&gt;abc,010,01/10/2017,05/12/2017&lt;BR /&gt;abc,010,08/01/2019,08/13/2019&lt;BR /&gt;abc,010,10/02/2018,10/09/2018&lt;BR /&gt;def,023,02/11/2017,02/14/2017&lt;BR /&gt;def,023,07/03/2016,07/30/2016&lt;BR /&gt;def,023,11/20/2017,11/26/2017&lt;BR /&gt;def,023,11/20/2017,04/20/2018&lt;BR /&gt;def,023,06/02/2017,07/02/2017&lt;BR /&gt;pqr,125,05/10/2013,05/20/2013&lt;BR /&gt;xyz,200,09/12/2015,09/18/2015&lt;BR /&gt;xyz,200,01/12/2016,11/22/2017&lt;BR /&gt;xyz,200,01/12/2016,01/21/2016&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please note that most of the subjects have multiple reg_dates and test_dates. How can I split the dates into multiple column. Like, reg_date1, reg_date2, reg_date3 . . . and also test_date1, test_date2 and so on.&lt;/P&gt;&lt;P&gt;So, the column of the output dataset will be like below.&lt;/P&gt;&lt;P&gt;name&amp;nbsp;&amp;nbsp; id&amp;nbsp;&amp;nbsp; reg_date1&amp;nbsp;&amp;nbsp; reg_date2&amp;nbsp;&amp;nbsp; reg_date3&amp;nbsp;&amp;nbsp; reg_date4&amp;nbsp;&amp;nbsp; reg_date5&amp;nbsp;&amp;nbsp; test_date1&amp;nbsp;&amp;nbsp; test_date2&amp;nbsp;&amp;nbsp; test_date3&amp;nbsp;&amp;nbsp; test_date4&amp;nbsp;&amp;nbsp; test_date5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ultimately one subject will have one row.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jul 2020 00:36:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-single-colum-data-into-multiple-column/m-p/667601#M23043</guid>
      <dc:creator>Barkat</dc:creator>
      <dc:date>2020-07-08T00:36:27Z</dc:date>
    </item>
    <item>
      <title>Re: Split single colum data into multiple column</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-single-colum-data-into-multiple-column/m-p/667604#M23044</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    by name;
    array regdt{5} reg_date1-reg_date5;
    array testdt{5} test_date1-test_date5;
    
    retain reg_date: test_date:;
    format reg_date: test_date: mmddyys10.;
    
    if first.name then counter=1;
    regdt{counter}=reg_dates;
    testdt{counter}=test_dates;
    if last.name then do;
        output;
        /* Added these call missing steps */
        call missing(of reg_date1-reg_date5);
        call missing (of test_date1-test_date5);
        end;
    
    counter+1;
    drop reg_dates test_dates counter;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ketpt42_0-1594172496285.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/46988iB0502FB447FAF389/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ketpt42_0-1594172496285.png" alt="ketpt42_0-1594172496285.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jul 2020 01:41:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-single-colum-data-into-multiple-column/m-p/667604#M23044</guid>
      <dc:creator>ketpt42</dc:creator>
      <dc:date>2020-07-08T01:41:55Z</dc:date>
    </item>
    <item>
      <title>Re: Split single colum data into multiple column</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-single-colum-data-into-multiple-column/m-p/667607#M23045</link>
      <description>&lt;P&gt;Thanks Ketpt42,&lt;/P&gt;&lt;P&gt;I was wondering why the missing dates of the subject pqr copied from the data just above. Same to xyz.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jul 2020 01:16:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-single-colum-data-into-multiple-column/m-p/667607#M23045</guid>
      <dc:creator>Barkat</dc:creator>
      <dc:date>2020-07-08T01:16:13Z</dc:date>
    </item>
    <item>
      <title>Re: Split single colum data into multiple column</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-single-colum-data-into-multiple-column/m-p/667609#M23046</link>
      <description>&lt;P&gt;Transposing data tutorials:&lt;BR /&gt;Long to Wide:&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/reshaping-data-long-to-wide-using-the-data-step/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/reshaping-data-long-to-wide-using-the-data-step/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;You're asking for a transposed format. You can either use PROC TRANSPOSE or a data step to accomplish this.&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/278672"&gt;@ketpt42&lt;/a&gt;&amp;nbsp;has provided the data step approach. The Transpose and Merge approach is less efficient - you need two transpose and one merge but is more dynamic so each method has its pros and cons.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The link above illustrates both methods.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jul 2020 01:18:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-single-colum-data-into-multiple-column/m-p/667609#M23046</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-08T01:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: Split single colum data into multiple column</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-single-colum-data-into-multiple-column/m-p/667614#M23047</link>
      <description>Oh, I forgot something. Let me modify the original code...</description>
      <pubDate>Wed, 08 Jul 2020 01:37:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-single-colum-data-into-multiple-column/m-p/667614#M23047</guid>
      <dc:creator>ketpt42</dc:creator>
      <dc:date>2020-07-08T01:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: Split single colum data into multiple column</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-single-colum-data-into-multiple-column/m-p/667650#M23054</link>
      <description>&lt;P&gt;Alternatively&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have out=want1(drop=_name_) prefix=reg_dates ;
by name id;
var reg_dates ;
run;

proc transpose data=have out=want2(drop=_name_) prefix=test_dates;
by name id;
var test_dates ;
run;

data want;
merge want1 want2;
by name id;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Jul 2020 08:15:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-single-colum-data-into-multiple-column/m-p/667650#M23054</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-07-08T08:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: Split single colum data into multiple column</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-single-colum-data-into-multiple-column/m-p/668405#M23114</link>
      <description>&lt;P&gt;May I ask a followup question, please.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was wondering if I have a column (comment) with text data in the same dataset then how do I split them into different columns (comment1, comment2, comment3, comment4, comment5)? I tried for long time, but failed. See the modified dataset below-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;infile datalines dsd dlm=',' ;&lt;BR /&gt;input name :$3. id :$3. reg_dates :MMDDYY10. test_dates :MMDDYY10. comment :$100.;&lt;BR /&gt;datalines;&lt;BR /&gt;abc,010,01/10/2017,01/20/2017,transferred to another hospital&lt;BR /&gt;abc,010,01/10/2017,05/12/2017,case has been closed&lt;BR /&gt;abc,010,08/01/2019,08/13/2019,unable to followup&lt;BR /&gt;abc,010,10/02/2018,10/09/2018,admin closure&lt;BR /&gt;def,023,02/11/2017,02/14/2017,transferred to another hospital&lt;BR /&gt;def,023,07/03/2016,07/30/2016,unable to followup&lt;BR /&gt;def,023,11/20/2017,11/26/2017,case has been closed&lt;BR /&gt;def,023,11/20/2017,04/20/2018,unable to followup&lt;BR /&gt;def,023,06/02/2017,07/02/2017,unable to followup&lt;BR /&gt;pqr,125,05/10/2013,05/20/2013,transferred to another hospital&lt;BR /&gt;xyz,200,09/12/2015,09/18/2015,case has been closed&lt;BR /&gt;xyz,200,01/12/2016,11/22/2017,transferred to another hospital&lt;BR /&gt;xyz,200,01/12/2016,01/21/2016,unable to followup&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2020 15:56:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-single-colum-data-into-multiple-column/m-p/668405#M23114</guid>
      <dc:creator>Barkat</dc:creator>
      <dc:date>2020-07-10T15:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: Split single colum data into multiple column</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-single-colum-data-into-multiple-column/m-p/668463#M23128</link>
      <description>&lt;P&gt;I tried the following program. But I have no idea, why the values for coment1-comment5 are missing in the want dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;by name;&lt;BR /&gt;array regdt{5} reg_date1-reg_date5;&lt;BR /&gt;array testdt{5} test_date1-test_date5;&lt;BR /&gt;array cmnt{5} comment1-comment5;&lt;BR /&gt;&lt;BR /&gt;retain reg_date: test_date: comment:;&lt;BR /&gt;format reg_date: test_date: mmddyys10.;&lt;BR /&gt;format comment $50.;&lt;BR /&gt;&lt;BR /&gt;if first.name then counter=1;&lt;BR /&gt;regdt{counter}=reg_dates;&lt;BR /&gt;testdt{counter}=test_dates;&lt;BR /&gt;cmnt{counter}=comment;&lt;/P&gt;&lt;P&gt;if last.name then do;&lt;BR /&gt;output;&lt;BR /&gt;/* Added these call missing steps */&lt;BR /&gt;call missing (of reg_date1-reg_date5);&lt;BR /&gt;call missing (of test_date1-test_date5);&lt;BR /&gt;call missing (of comment1-comment5);&lt;BR /&gt;end;&lt;BR /&gt;counter+1;&lt;BR /&gt;drop reg_dates test_dates counter comment;&lt;BR /&gt;*putlog _all_;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc print data=want; run;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2020 19:47:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-single-colum-data-into-multiple-column/m-p/668463#M23128</guid>
      <dc:creator>Barkat</dc:creator>
      <dc:date>2020-07-10T19:47:19Z</dc:date>
    </item>
    <item>
      <title>Re: Split single colum data into multiple column</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-single-colum-data-into-multiple-column/m-p/668466#M23130</link>
      <description>&lt;P&gt;You need to declare your comment array as character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    by name;
    array regdt{5} reg_date1-reg_date5;
    array testdt{5} test_date1-test_date5;
    array cmnt{5} $100 comment1-comment5;
    
    
    retain reg_date: test_date: comment:;
    format reg_date: test_date: mmddyys10. comment: $100.;
    
    if first.name then counter=1;
    regdt{counter}=reg_dates;
    testdt{counter}=test_dates;
    cmnt{counter}=comment;
    if last.name then do;
        output;
        /* Added these call missing steps */
        call missing(of reg_date1-reg_date5);
        call missing (of test_date1-test_date5);
        call missing (of comment1-comment5);
        end;
        
    counter+1;
    drop reg_dates test_dates counter comment;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Jul 2020 19:57:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-single-colum-data-into-multiple-column/m-p/668466#M23130</guid>
      <dc:creator>ketpt42</dc:creator>
      <dc:date>2020-07-10T19:57:59Z</dc:date>
    </item>
    <item>
      <title>Re: Split single colum data into multiple column</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Split-single-colum-data-into-multiple-column/m-p/668468#M23131</link>
      <description>&lt;P&gt;Or expand&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12151"&gt;@Jagadishkatam&lt;/a&gt;'s example into a triple transpose:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have out=want1(drop=_name_) prefix=reg_date;
by name id;
var reg_dates ;
run;

proc transpose data=have out=want2(drop=_name_) prefix=test_date;
by name id;
var test_dates ;
run;

proc transpose data=have out=want3(drop=_name_) prefix=comment;
by name id;
var comment ;
run;

data want;
merge want1 want2 want3;
by name id;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Jul 2020 20:01:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Split-single-colum-data-into-multiple-column/m-p/668468#M23131</guid>
      <dc:creator>ketpt42</dc:creator>
      <dc:date>2020-07-10T20:01:50Z</dc:date>
    </item>
  </channel>
</rss>

