<?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: Have to separate string into 3 where the delimiter appears to be one space in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291485#M60392</link>
    <description>&lt;PRE&gt;
You could use more rigorous version of scan() with 'kd' option:



data _null_;
 length t1 t2 x $ 40;
 x='111'||'09'x||'222'||'0A'x||'333';
 t1=scan(x,1,,'s');
 t2=scan(x,1,,'kd');
 put t1= t2=;
 t1=scan(x,2,,'s');
 t2=scan(x,2,,'kd');
 put t1= t2=;
 t1=scan(x,3,,'s');
 t2=scan(x,3,,'kd');
 put t1= t2=;
run;
&lt;/PRE&gt;</description>
    <pubDate>Sat, 13 Aug 2016 05:51:53 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-08-13T05:51:53Z</dc:date>
    <item>
      <title>Have to separate string into 3 where the delimiter appears to be one space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291238#M60333</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 10million records, all that look like this: 2005370806&amp;#1; 20151201 &amp;#1;2&lt;/P&gt;&lt;P&gt;The length of charcters between spaces are NOT the same across al records.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ive tried compbl and then scan function and nothing works!! i cant seem to separate this string. Please help!!&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 13:06:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291238#M60333</guid>
      <dc:creator>vera843</dc:creator>
      <dc:date>2016-08-12T13:06:35Z</dc:date>
    </item>
    <item>
      <title>Re: Have to separate string into 3 where the delimiter appears to be one space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291242#M60334</link>
      <description>&lt;P&gt;I am afraid "&lt;SPAN&gt;Ive tried compbl and then scan function and nothing works!!" isn't really descriptive of the problem. &amp;nbsp;Post some test data in the form of a datastep and what code you have tried. &amp;nbsp;Scan is the perfect function for such a thing, as this will demonostrate:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;data want;
  original="2005370806&amp;#1; 20151201 &amp;#1;2";
  want1=scan(original,1," ");
  want2=scan(original,2," ");
  want3=scan(original,3," ");
run;

&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Aug 2016 13:17:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291242#M60334</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-08-12T13:17:45Z</dc:date>
    </item>
    <item>
      <title>Re: Have to separate string into 3 where the delimiter appears to be one space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291245#M60336</link>
      <description>&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; rmd.calls;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; rmd.calls;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;new=compbl(poid);&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; rmd.calls;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; rmd.calls;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;POID=SCAN (new,&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;' '&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;call_date =SCAN (new,&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;2&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;' '&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;calls =SCAN (new,&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;3&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;' '&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;The above returns blanks for call_date and calls and puts the entre string again for poid&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 13:24:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291245#M60336</guid>
      <dc:creator>vera843</dc:creator>
      <dc:date>2016-08-12T13:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: Have to separate string into 3 where the delimiter appears to be one space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291247#M60337</link>
      <description>&lt;P&gt;I can't really tell you as I can't see your data, follow this post and give us a couple of lines of test data so we can see it:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At a guess, I would say your delimiter - ' ' does not match the delimiter in your data, could it be that it is a secret tab or something else?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 13:40:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291247#M60337</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-08-12T13:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: Have to separate string into 3 where the delimiter appears to be one space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291250#M60338</link>
      <description>&lt;P&gt;But this is why I did function compbl first&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 13:48:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291250#M60338</guid>
      <dc:creator>vera843</dc:creator>
      <dc:date>2016-08-12T13:48:32Z</dc:date>
    </item>
    <item>
      <title>Re: Have to separate string into 3 where the delimiter appears to be one space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291251#M60339</link>
      <description>&lt;P&gt;Look at the options for SCAN. I think there's an option for all space types.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 13:52:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291251#M60339</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-12T13:52:14Z</dc:date>
    </item>
    <item>
      <title>Re: Have to separate string into 3 where the delimiter appears to be one space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291252#M60340</link>
      <description>&lt;P&gt;I think the use of compbl() is not to be done because index() looks for embedded space to break the string.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 13:52:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291252#M60340</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2016-08-12T13:52:50Z</dc:date>
    </item>
    <item>
      <title>Re: Have to separate string into 3 where the delimiter appears to be one space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291254#M60341</link>
      <description>&lt;P&gt;The function COMBL:&lt;/P&gt;
&lt;P&gt;"&lt;SPAN&gt;The COMPBL function removes multiple blanks in a character string by translating each occurrence of two or more consecutive blanks into a single blank."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;It does not remove special characters such as tabs. &amp;nbsp;For example if you run this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;data want;
  text="abcdef"||'09'x||"defe";
run;
ods rtf file="c:\test.rtf";
proc print data=want;
run;
ods rtf close;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;The data will not show any blanks, however when printed the tab comes into effect - these are special characters.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 13:55:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291254#M60341</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-08-12T13:55:41Z</dc:date>
    </item>
    <item>
      <title>Re: Have to separate string into 3 where the delimiter appears to be one space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291255#M60342</link>
      <description>&lt;P&gt;Are you able to provide how to use index in this example? I know Ive used Index to look for certain pieces in a string but never spaces&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 13:57:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291255#M60342</guid>
      <dc:creator>vera843</dc:creator>
      <dc:date>2016-08-12T13:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: Have to separate string into 3 where the delimiter appears to be one space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291257#M60343</link>
      <description>&lt;P&gt;X = scan(word, 1, , 'c');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What about this?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 14:04:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291257#M60343</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-12T14:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: Have to separate string into 3 where the delimiter appears to be one space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291258#M60344</link>
      <description>&lt;P&gt;You are right, I did index to look for spaces and there are not any although when printed i see spaces.&lt;/P&gt;&lt;P&gt;Now what?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 14:05:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291258#M60344</guid>
      <dc:creator>vera843</dc:creator>
      <dc:date>2016-08-12T14:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: Have to separate string into 3 where the delimiter appears to be one space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291260#M60345</link>
      <description>&lt;P&gt;If that doesn't work, use a HEX format to display your results to identify your delimiter.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 14:05:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291260#M60345</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-12T14:05:57Z</dc:date>
    </item>
    <item>
      <title>Re: Have to separate string into 3 where the delimiter appears to be one space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291305#M60366</link>
      <description>&lt;P&gt;You can try &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;'s suggestion by using 's' modifier in the SCAN(),&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  text="abcdef"||'09'x||"defe";
   do i=1 to 2;
   _s1=scan(text,i,'','s');
    output;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If this does not work out, try another suggestion also provided by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;, to print out all chars in HEX, then you will be able to pinpoint your delimiter, of course, only try it on serveral obs to figure it out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  text="abcdef"||'09'x||"defe";
  len=length(text);
  do i=1 to len;
  char=char(text,i);
  hex=put(char,$hex2.);
  output;
   end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As you can see from above example, after running, 7th(i=7) is a tab, hex=09, so next is easy:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  text="abcdef"||'09'x||"defe";
   do i=1 to 2;
   _s1=scan(text,i,'09'x);
    output;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Aug 2016 15:49:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291305#M60366</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2016-08-12T15:49:38Z</dc:date>
    </item>
    <item>
      <title>Re: Have to separate string into 3 where the delimiter appears to be one space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291485#M60392</link>
      <description>&lt;PRE&gt;
You could use more rigorous version of scan() with 'kd' option:



data _null_;
 length t1 t2 x $ 40;
 x='111'||'09'x||'222'||'0A'x||'333';
 t1=scan(x,1,,'s');
 t2=scan(x,1,,'kd');
 put t1= t2=;
 t1=scan(x,2,,'s');
 t2=scan(x,2,,'kd');
 put t1= t2=;
 t1=scan(x,3,,'s');
 t2=scan(x,3,,'kd');
 put t1= t2=;
run;
&lt;/PRE&gt;</description>
      <pubDate>Sat, 13 Aug 2016 05:51:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Have-to-separate-string-into-3-where-the-delimiter-appears-to-be/m-p/291485#M60392</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-08-13T05:51:53Z</dc:date>
    </item>
  </channel>
</rss>

