<?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: How to read delimiter if it's a multiple spaces in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666409#M199382</link>
    <description>&lt;P&gt;Not sure what the latest question is, but if you don't tell SAS explicitly how to define a variable it must make its own guess.&amp;nbsp; So in your code the first place new variables TRANSLATE&amp;nbsp; and TRANSLATE2 are seen is being assigned the result of a character function.&amp;nbsp; So SAS will define them as length 200.&amp;nbsp; You should define them first using a LENGTH statement.&amp;nbsp; Or if for some reason you don't know the length you need you can trick SAS into defining them as being the same length as FLEX_VALUE_1 by adding extra assignment statements.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;translate=FLEX_VALUE_1;
translate=tranwrd(FLEX_VALUE_1,'   ','|'); 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 01 Jul 2020 15:28:17 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-07-01T15:28:17Z</dc:date>
    <item>
      <title>How to read delimiter if it's a multiple spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666348#M199352</link>
      <description>&lt;P&gt;I have a data that uses multiple spaces (3 spaces) as a delimiter:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;data have;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;input text&amp;amp;$100.;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;cards;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Last_Name, First_Name Middle_Name 123456789 Company NameX;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;data want;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;set have;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;want=scan(text,1,' ');&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I used the scan function and specify the 3 spaces for my delimiter but it doesn't work. I could have used COMPBL function to get rid of the multiple spaces but my issue on that is Full Name and Company Name have spaces(single space) as well so they will be seperated&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 12:11:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666348#M199352</guid>
      <dc:creator>iSAS</dc:creator>
      <dc:date>2020-07-01T12:11:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to read delimiter if it's a multiple spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666349#M199353</link>
      <description>&lt;P&gt;What 3 spaces are you referring to?&amp;nbsp;You didn't provide any actual data&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 12:15:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666349#M199353</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-01T12:15:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to read delimiter if it's a multiple spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666350#M199354</link>
      <description>Thank you for your time. This is the sample:&lt;BR /&gt;Last_Name, First_Name Middle_Name 123456789 Company NameX;&lt;BR /&gt;I even used this function to get the Company_Name but it doesn't work also:&lt;BR /&gt;Company_Name=scan(have,-1,index(have,' '));</description>
      <pubDate>Wed, 01 Jul 2020 12:19:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666350#M199354</guid>
      <dc:creator>iSAS</dc:creator>
      <dc:date>2020-07-01T12:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to read delimiter if it's a multiple spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666351#M199355</link>
      <description>&lt;P&gt;There are no multiple spaces in this sample data. So I still don't understand the question.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 12:25:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666351#M199355</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-01T12:25:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to read delimiter if it's a multiple spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666352#M199356</link>
      <description>Last_Name, First_Name Middle_Nam**with 3 spaces**123456789**3 spaces**Company NameX;</description>
      <pubDate>Wed, 01 Jul 2020 12:30:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666352#M199356</guid>
      <dc:creator>iSAS</dc:creator>
      <dc:date>2020-07-01T12:30:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to read delimiter if it's a multiple spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666355#M199357</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Please provide example data so we can better understand your problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you looking for something like this (dlmstr option)?&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;filename a temp;

data _NULL_;
file a;
put "foo   b  ar   ba z";
run;

data have;
length x y z $20.;
infile a dlmstr="   ";
input x y z ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 12:40:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666355#M199357</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2020-07-01T12:40:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to read delimiter if it's a multiple spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666358#M199360</link>
      <description>&lt;P&gt;It also works with datalines:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length x y z $20.;
infile datalines dlmstr="   ";
input x y z;
datalines;
foo   b  ar   ba z
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 12:52:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666358#M199360</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-01T12:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to read delimiter if it's a multiple spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666361#M199362</link>
      <description>&lt;P&gt;Yes, i used a temporary file as i suspect that &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/132557"&gt;@iSAS&lt;/a&gt; data come in the form of an external file but i may be wrong.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 13:01:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666361#M199362</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2020-07-01T13:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to read delimiter if it's a multiple spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666363#M199363</link>
      <description>&lt;P&gt;Posting code in the main posting window will cause text to be used in HTML, which means any sequence of white space is condensed into a single blank.&lt;/P&gt;
&lt;P&gt;That's why it is an ABSOLUTE MUST to use the "little running man" button (right next to the one indicated in the picture) for code:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg"&gt;&lt;img src="https://communities.sas.com/skins/images/2FD96521DCF95C42FE57BF2A7CB72678/responsive_peak/images/image_not_found.png" alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 13:07:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666363#M199363</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-01T13:07:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to read delimiter if it's a multiple spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666373#M199366</link>
      <description>Thank you for your time KurtBremser. What if my data is already a sas dataset in 1 column, may I know how will I translate the given solution?</description>
      <pubDate>Wed, 01 Jul 2020 13:39:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666373#M199366</guid>
      <dc:creator>iSAS</dc:creator>
      <dc:date>2020-07-01T13:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to read delimiter if it's a multiple spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666376#M199368</link>
      <description>&lt;P&gt;Do you only have the text already in a dataset? Or are you reading the text from a file?&lt;/P&gt;
&lt;P&gt;Does the data ever have 2 spaces that you don't want to treat as a delimiter?&lt;/P&gt;
&lt;P&gt;If not then just the the &amp;amp; modifier on the INPUT statement and SAS will not use only a single space as a delimiter.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  length person $100 id $20 compary $50 ;
  input person &amp;amp;  id &amp;amp; company &amp;amp; ;
cards;
Last_Name, First_Name Middle_Name   123456789   Company NameX
;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;Obs                 person                     id           company

 1     Last_Name, First_Name Middle_Name    123456789    Company NameX&lt;/PRE&gt;
&lt;P&gt;If you only have the string variable then first convert the triple spaces to some character that is not in the data and use that in the SCAN() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  length company $50;
  company=scan(tranwrd(text,'   ','FF'x),-1,'FF'x);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Jul 2020 13:51:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666376#M199368</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-01T13:51:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to read delimiter if it's a multiple spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666380#M199369</link>
      <description>&lt;P&gt;You can use&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/30622"&gt;@gamotte&lt;/a&gt;'s "trick" and use a temporary file:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
x1 = "aaa   bbb   ccc";
run;

filename a temp;

data _null_;
set have;
file a;
put x1;
run;

data h2;
infile a dlmstr="   ";
input x2 $ x3 $ x4 $;
run;

data want;
merge have h2;
run;

filename a clear;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Jul 2020 13:58:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666380#M199369</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-01T13:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to read delimiter if it's a multiple spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666397#M199372</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;Thanks to all who helped me! I encountered additional issue on my data but all your suggestions helped fix the issue. What i did was this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;set have (keep=FLEX_VALUE_1);&lt;BR /&gt;translate=tranwrd(FLEX_VALUE_1,' ','|'); /*The issue of this is all of the length of my data is 200*/&lt;BR /&gt;translate2=tranwrd(FLEX_VALUE_1,' ',''); /*This was created to get the actual length needed in translate variable. This wasn't used in the first place bec., after testing, it will have an issue on scan function. the issue has something to do with the data itself*/&lt;BR /&gt;/*numb=length(translate2); This was used for testing*/&lt;BR /&gt;value=substr(translate,1,length(translate2));/*To only get the needeed value of translate*/&lt;BR /&gt;NAme= SCAN(value, 1, '|');&lt;BR /&gt;Account = PUT(INPUT(SCAN(value, 2, '|'), best.) , z11.);&lt;BR /&gt;company = SCAN(value, -1, '|');&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Feel free to share your kowledge if you have suggestions to improve my code or if you see some errors so i could learn from you guys. thanks you so much!&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 14:50:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666397#M199372</guid>
      <dc:creator>iSAS</dc:creator>
      <dc:date>2020-07-01T14:50:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to read delimiter if it's a multiple spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666409#M199382</link>
      <description>&lt;P&gt;Not sure what the latest question is, but if you don't tell SAS explicitly how to define a variable it must make its own guess.&amp;nbsp; So in your code the first place new variables TRANSLATE&amp;nbsp; and TRANSLATE2 are seen is being assigned the result of a character function.&amp;nbsp; So SAS will define them as length 200.&amp;nbsp; You should define them first using a LENGTH statement.&amp;nbsp; Or if for some reason you don't know the length you need you can trick SAS into defining them as being the same length as FLEX_VALUE_1 by adding extra assignment statements.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;translate=FLEX_VALUE_1;
translate=tranwrd(FLEX_VALUE_1,'   ','|'); 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Jul 2020 15:28:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-delimiter-if-it-s-a-multiple-spaces/m-p/666409#M199382</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-01T15:28:17Z</dc:date>
    </item>
  </channel>
</rss>

