<?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: Extract words separated by delimiters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extract-words-separated-by-delimiters/m-p/757623#M239174</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;Thanks. I need line breaks when there is any special character in the string as I shown in example. Can't we achieve it using scan function or something similar instead of prxchange?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you want to code the loop manually, countw+scan could be used, but why? You can, of course, replace [[:punct:]] with "any special char", some need to be escaped with \, like the dot.&lt;/P&gt;</description>
    <pubDate>Wed, 28 Jul 2021 09:36:02 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2021-07-28T09:36:02Z</dc:date>
    <item>
      <title>Extract words separated by delimiters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-words-separated-by-delimiters/m-p/757597#M239158</link>
      <description>&lt;P&gt;Given the following alphanumeric variable VAR1 :&lt;/P&gt;
&lt;PRE&gt;VAR1 = "Is this the real life? Is this just fantasy? Caught in a
landslide. No escape from reality!";&lt;/PRE&gt;
&lt;P&gt;May I know which function yields this excepted results?&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Is this the real life
Is this just fantasy 
Caught in a landslide
No escape from reality&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Jul 2021 06:39:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-words-separated-by-delimiters/m-p/757597#M239158</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-07-28T06:39:20Z</dc:date>
    </item>
    <item>
      <title>Re: Extract words separated by delimiters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-words-separated-by-delimiters/m-p/757598#M239159</link>
      <description>&lt;P&gt;Do you really want line breaks in values? Please explain the rules to add line breaks.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data narf;
   length var1 var2 $ 100;

   VAR1 = "Is this the real life? Is this just fantasy? Caught in a landslide. No escape from reality!";
   var2 = prxchange('s/[[:punct:]]/^n/', -1, var1);
run;

ods escapechar='^';

proc print;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Jul 2021 06:55:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-words-separated-by-delimiters/m-p/757598#M239159</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-07-28T06:55:46Z</dc:date>
    </item>
    <item>
      <title>Re: Extract words separated by delimiters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-words-separated-by-delimiters/m-p/757607#M239165</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;Thanks. I need line breaks when there is any special character in the string as I shown in example. Can't we achieve it using scan function or something similar instead of prxchange?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 07:47:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-words-separated-by-delimiters/m-p/757607#M239165</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-07-28T07:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: Extract words separated by delimiters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-words-separated-by-delimiters/m-p/757608#M239166</link>
      <description>&lt;P&gt;COUNTW and SCAN, with the proper selection of delimiters:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
VAR1 = "Is this the real life? Is this just fantasy? Caught in a
landslide. No escape from reality!";
do i = 1 to countw(var1,".!?");
  text = scan(var1,i,".!?");
  output;
end;
keep text;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Jul 2021 07:49:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-words-separated-by-delimiters/m-p/757608#M239166</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-07-28T07:49:15Z</dc:date>
    </item>
    <item>
      <title>Re: Extract words separated by delimiters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-words-separated-by-delimiters/m-p/757610#M239168</link>
      <description>&lt;P&gt;You can insert line breaks into the variable by using TRANSLATE:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
VAR1 = "Is this the real life? Is this just fantasy? Caught in a landslide. No escape from reality!";
var1 = translate(var1,'0a0a0a'x,'.!?');
checkvar = put(var1,$hex200.);
put checkvar=;
run;

data _null_;
set want;
file '/folders/myfolders/test.txt';
put var1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRIKE&gt;Note that the character used will depend on the environment used to open the file; I use CR because I work on a Mac and inspected the file with TextMate and TextEdit.&lt;/STRIKE&gt; Since I actually used LF (0A) already, this should be the way to go.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may find that LF (0Ax) is more appropriate for things like Excel.&lt;/P&gt;
&lt;P&gt;Also note that SAS will not show the line breaks when viewing the file or creating output (e.g. with PROC PRINT).&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 08:09:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-words-separated-by-delimiters/m-p/757610#M239168</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-07-28T08:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: Extract words separated by delimiters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-words-separated-by-delimiters/m-p/757623#M239174</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;Thanks. I need line breaks when there is any special character in the string as I shown in example. Can't we achieve it using scan function or something similar instead of prxchange?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you want to code the loop manually, countw+scan could be used, but why? You can, of course, replace [[:punct:]] with "any special char", some need to be escaped with \, like the dot.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 09:36:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-words-separated-by-delimiters/m-p/757623#M239174</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-07-28T09:36:02Z</dc:date>
    </item>
    <item>
      <title>Re: Extract words separated by delimiters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-words-separated-by-delimiters/m-p/757702#M239200</link>
      <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Count-words/m-p/753521#M237506" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Count-words/m-p/753521#M237506&lt;/A&gt; &lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 14:17:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-words-separated-by-delimiters/m-p/757702#M239200</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-07-28T14:17:13Z</dc:date>
    </item>
  </channel>
</rss>

