<?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 Separate the Name text into different columns by comma? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Separate-the-Name-text-into-different-columns-by-comma/m-p/676883#M204114</link>
    <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a sample dataset 'datain1',&amp;nbsp; it contains a column 'Name'&amp;nbsp;mixed with some various text separated by comma ' , '.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to distribute the 'Name' text into different columns, result1-result3, based on the&amp;nbsp;comma ' , '.&amp;nbsp;&amp;nbsp;&amp;nbsp; Please&amp;nbsp;check the result I am looking for is 'Dataout1'&lt;/P&gt;
&lt;P&gt;Please let me know how to approach it.&amp;nbsp;&amp;nbsp; One thing I would like to point out that the 'Name' text includes different mixed names, sometime only have one name, sometime have three names, sometime have&amp;nbsp;multiple names.&amp;nbsp;&amp;nbsp; Therefore, the 'result' columns should be based on the largest 'Name' numbers in the 'Name' text.&amp;nbsp; The result3 column in the dataset is only the sample dataset&amp;nbsp;I created.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data datain1;
      infile datalines delimiter='/';
  input Name : $300.  ;
datalines;
	ACUTE OTITIS MEDIA,ASTIGMATISM, CONSTIPATION/
	ACUTE URI, GERD/
	BILATERAL. HYDRONEPHROSIS/
;
run;


data dataout1;
      infile datalines delimiter='/';
  input Name : $300.  Result1 : $100. Result2 : $100. Result3 : $100.;
datalines;
	ACUTE OTITIS MEDIA,ASTIGMATISM, CONSTIPATION/ACUTE OTITIS MEDIA/ASTIGMATISM/CONSTIPATION
	ACUTE URI, GERD/ACUTE URI/GERD/ /
	BILATERAL. HYDRONEPHROSIS/BILATERAL. HYDRONEPHROSIS/ / /
;
run;&lt;/PRE&gt;</description>
    <pubDate>Fri, 14 Aug 2020 20:49:45 GMT</pubDate>
    <dc:creator>ybz12003</dc:creator>
    <dc:date>2020-08-14T20:49:45Z</dc:date>
    <item>
      <title>Separate the Name text into different columns by comma?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separate-the-Name-text-into-different-columns-by-comma/m-p/676883#M204114</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a sample dataset 'datain1',&amp;nbsp; it contains a column 'Name'&amp;nbsp;mixed with some various text separated by comma ' , '.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to distribute the 'Name' text into different columns, result1-result3, based on the&amp;nbsp;comma ' , '.&amp;nbsp;&amp;nbsp;&amp;nbsp; Please&amp;nbsp;check the result I am looking for is 'Dataout1'&lt;/P&gt;
&lt;P&gt;Please let me know how to approach it.&amp;nbsp;&amp;nbsp; One thing I would like to point out that the 'Name' text includes different mixed names, sometime only have one name, sometime have three names, sometime have&amp;nbsp;multiple names.&amp;nbsp;&amp;nbsp; Therefore, the 'result' columns should be based on the largest 'Name' numbers in the 'Name' text.&amp;nbsp; The result3 column in the dataset is only the sample dataset&amp;nbsp;I created.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data datain1;
      infile datalines delimiter='/';
  input Name : $300.  ;
datalines;
	ACUTE OTITIS MEDIA,ASTIGMATISM, CONSTIPATION/
	ACUTE URI, GERD/
	BILATERAL. HYDRONEPHROSIS/
;
run;


data dataout1;
      infile datalines delimiter='/';
  input Name : $300.  Result1 : $100. Result2 : $100. Result3 : $100.;
datalines;
	ACUTE OTITIS MEDIA,ASTIGMATISM, CONSTIPATION/ACUTE OTITIS MEDIA/ASTIGMATISM/CONSTIPATION
	ACUTE URI, GERD/ACUTE URI/GERD/ /
	BILATERAL. HYDRONEPHROSIS/BILATERAL. HYDRONEPHROSIS/ / /
;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Aug 2020 20:49:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separate-the-Name-text-into-different-columns-by-comma/m-p/676883#M204114</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2020-08-14T20:49:45Z</dc:date>
    </item>
    <item>
      <title>Re: Separate the Name text into different columns by comma?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separate-the-Name-text-into-different-columns-by-comma/m-p/676889#M204116</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data datain1;
      infile datalines delimiter='/';
  input Name : $300.  ;
  length String1 String2 String3 $300;
  array _string{*} String1 String2 String3;
  end=countc(Name,',')+1;
  do i = 1 to end;
     _String[i] = scan(strip(Name),i,',');
	 
  end;
datalines;
	ACUTE OTITIS MEDIA,ASTIGMATISM, CONSTIPATION/
	ACUTE URI, GERD/
	BILATERAL. HYDRONEPHROSIS/
;;;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Aug 2020 21:03:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separate-the-Name-text-into-different-columns-by-comma/m-p/676889#M204116</guid>
      <dc:creator>smantha</dc:creator>
      <dc:date>2020-08-14T21:03:56Z</dc:date>
    </item>
    <item>
      <title>Re: Separate the Name text into different columns by comma?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separate-the-Name-text-into-different-columns-by-comma/m-p/676899#M204119</link>
      <description>Awesome, thanks.</description>
      <pubDate>Fri, 14 Aug 2020 21:32:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separate-the-Name-text-into-different-columns-by-comma/m-p/676899#M204119</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2020-08-14T21:32:25Z</dc:date>
    </item>
    <item>
      <title>Re: Separate the Name text into different columns by comma?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separate-the-Name-text-into-different-columns-by-comma/m-p/676902#M204120</link>
      <description>&lt;P&gt;One more thing, how to change the 'end' number to the largest string number.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;length String1 - String(end) $300;
	array _string{*} String1 - String(end);
	  end=countc(name,',')+1;
	  do i = 1 to end;
	     _String[i] = scan(strip(name),i,',');
  	end;&lt;/PRE&gt;
&lt;P&gt;I tried, and it didn't work.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Aug 2020 21:55:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separate-the-Name-text-into-different-columns-by-comma/m-p/676902#M204120</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2020-08-14T21:55:15Z</dc:date>
    </item>
  </channel>
</rss>

