<?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: Divide text into columns in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Divide-text-into-columns/m-p/945672#M370463</link>
    <description>&lt;P&gt;Thanks a lot for clarifying.&lt;/P&gt;</description>
    <pubDate>Mon, 30 Sep 2024 10:50:59 GMT</pubDate>
    <dc:creator>laxmanpai</dc:creator>
    <dc:date>2024-09-30T10:50:59Z</dc:date>
    <item>
      <title>Divide text into columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Divide-text-into-columns/m-p/945445#M370406</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a Text below;&lt;/P&gt;
&lt;P&gt;abcd15ppppp&lt;/P&gt;
&lt;P&gt;bvcsf24dsfd&lt;/P&gt;
&lt;P&gt;cadadada30fdsfdsf&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The final output should look like below with 3 columns:&lt;/P&gt;
&lt;P&gt;col1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; col2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;col3&lt;/P&gt;
&lt;P&gt;abcd&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;ppppp&lt;/P&gt;
&lt;P&gt;bvcsf&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 24&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;dsfd&lt;/P&gt;
&lt;P&gt;cadadada&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;fdsfdsf&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please help me here&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;P&gt;Laxman&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2024 12:17:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Divide-text-into-columns/m-p/945445#M370406</guid>
      <dc:creator>laxmanpai</dc:creator>
      <dc:date>2024-09-27T12:17:36Z</dc:date>
    </item>
    <item>
      <title>Re: Divide text into columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Divide-text-into-columns/m-p/945448#M370408</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    where1=anydigit(text);
    where2=anyalpha(text,where1);
    string1=substr(text,1,where1-1);
    string2=substr(text,where1,where2-where1);
    string3=substr(text,where2);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Sep 2024 12:26:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Divide-text-into-columns/m-p/945448#M370408</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-09-27T12:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: Divide text into columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Divide-text-into-columns/m-p/945449#M370409</link>
      <description>&lt;P&gt;And of course thee are multiple ways of doing it in SAS:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	length text $20;
	input text;
	datalines;
abcd15ppppp
bvcsf24dsfd
cadadada30fdsfdsf
;
run;

data want;
	set have;
	col1 = scan(text,1,,'D');
	col2 = scan(text,1,,'AI');
	col3 = scan(text,2,,'D');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Sep 2024 12:30:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Divide-text-into-columns/m-p/945449#M370409</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2024-09-27T12:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: Divide text into columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Divide-text-into-columns/m-p/945450#M370410</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I did not get the code you have written. Could you please elaborate what these 3 statements do and how do they get split&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;data want;
	set have;
	col1 = scan(text,1,,'D');
	col2 = scan(text,1,,'AI');
	col3 = scan(text,2,,'D');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2024 12:43:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Divide-text-into-columns/m-p/945450#M370410</guid>
      <dc:creator>laxmanpai</dc:creator>
      <dc:date>2024-09-27T12:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: Divide text into columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Divide-text-into-columns/m-p/945453#M370411</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/28829"&gt;@laxmanpai&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I did not get the code you have written. Could you please elaborate what these 3 statements do and how do they get split&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;data want;
	set have;
	col1 = scan(text,1,,'D');
	col2 = scan(text,1,,'AI');
	col3 = scan(text,2,,'D');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Read the SCAN() function documentation.&amp;nbsp; Make sure the check the meaning of the A,D and I modifiers.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2024 13:01:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Divide-text-into-columns/m-p/945453#M370411</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-09-27T13:01:22Z</dc:date>
    </item>
    <item>
      <title>Re: Divide text into columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Divide-text-into-columns/m-p/945663#M370459</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The modifier 'A' -&amp;nbsp;&lt;SPAN&gt;Adds alphabetic characters to the list of characters&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;'D' -&amp;nbsp;Adds digits to the list of characters.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;But &lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;col1 = scan(text,1,,'D');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;will output Peter but 'D' represents the Digits right ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please clarify&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2024 10:17:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Divide-text-into-columns/m-p/945663#M370459</guid>
      <dc:creator>laxmanpai</dc:creator>
      <dc:date>2024-09-30T10:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: Divide text into columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Divide-text-into-columns/m-p/945668#M370460</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the first line in the input statement is as follows :&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;abcd15ppppp&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;col1= scan(text,1, , 'D') should result in 15 right?, but it would output abcd.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please clarify.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2024 10:25:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Divide-text-into-columns/m-p/945668#M370460</guid>
      <dc:creator>laxmanpai</dc:creator>
      <dc:date>2024-09-30T10:25:15Z</dc:date>
    </item>
    <item>
      <title>Re: Divide text into columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Divide-text-into-columns/m-p/945670#M370461</link>
      <description>&lt;P&gt;The result of this command should be abcd, not 15. The 'D' modifier indicates digits are the separator between "words", so the first word ends when the 15 appears, the first word is abcd.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2024 10:40:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Divide-text-into-columns/m-p/945670#M370461</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-09-30T10:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: Divide text into columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Divide-text-into-columns/m-p/945672#M370463</link>
      <description>&lt;P&gt;Thanks a lot for clarifying.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2024 10:50:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Divide-text-into-columns/m-p/945672#M370463</guid>
      <dc:creator>laxmanpai</dc:creator>
      <dc:date>2024-09-30T10:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: Divide text into columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Divide-text-into-columns/m-p/945690#M370468</link>
      <description>&lt;P&gt;The D (and A) modifiers add characters to the list of delimiter characters.&lt;/P&gt;
&lt;P&gt;D means Digits and A means Alphabet.&lt;/P&gt;
&lt;P&gt;So the command&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;col1= scan(text,1, , 'D');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is the same as the command&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;col1= scan(text,1,'0123456789')&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Remember that when there are multiple adjacent delimiter it only causes one split in the list.&lt;/P&gt;
&lt;P&gt;So&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;scan('abcd15xyz',1,'0123456789')&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Will return abcd as that is the first "word" before the first delimiter.&lt;/P&gt;
&lt;P&gt;Also when the string starts with the delimiters the first word is after the first block of delimiters.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;scan('abcd15xyz',1,,'A')&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;will return '15' since the leading block of letters is skipped over and the trailing block of letters marks the end of the first word.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The way to remember this is that it is basically doing what you would do when reading a space delimited list of words.&amp;nbsp; For both of these strings:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ONE TWO THREE
      ONE       TWO     THREE&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The first word is "ONE" and the second word is "TWO".&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2024 13:56:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Divide-text-into-columns/m-p/945690#M370468</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-09-30T13:56:18Z</dc:date>
    </item>
  </channel>
</rss>

