<?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: Delete text on the left before a blank line (kw) in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Delete-text-on-the-left-before-a-blank-line-kw/m-p/560817#M10504</link>
    <description>Thank you for the message,&lt;BR /&gt;I will add that : I have one input variable, I'm looking to keep only the last line of text in it.&lt;BR /&gt;&lt;BR /&gt;1) I don't know the number of lines , it's *PLAIN TEXT*&lt;BR /&gt;2) I don't know the number of '0A'x in the variable&lt;BR /&gt;3) How to treat lines of text ( plain text) as a delimiter ? ( it's not about rows and columns, but plain text)&lt;BR /&gt;&lt;BR /&gt;Thank you for response.&lt;BR /&gt;&lt;BR /&gt;Sincerely.</description>
    <pubDate>Wed, 22 May 2019 13:03:04 GMT</pubDate>
    <dc:creator>SIgnificatif</dc:creator>
    <dc:date>2019-05-22T13:03:04Z</dc:date>
    <item>
      <title>Delete text on the left before a blank line (kw)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delete-text-on-the-left-before-a-blank-line-kw/m-p/560434#M10461</link>
      <description>&lt;P&gt;Hi All.&lt;BR /&gt;&lt;BR /&gt;I'm looking into ways to delete left part of the text before a blank line, i'm giving example of a similar code that remove everything before the '|' character, are there ways to do the same before the blank line ?&amp;nbsp; ( or keep only the last line) I need only to keep the text on the last line ( where the keword another starts, but the keyword is not constant, so another solution is needed) :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length textstr $100;
input textstr $;
datalines;
Text text text 

&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Another text , text text&lt;/STRONG&gt;&lt;/FONT&gt;
;;;;
run;

data want;
  set have;
  call scan(textstr,2,start,length,'|');
  new_textstr = substr(textstr,start);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have tried also the compress, where it looks for the kw, but this is something difficult to combine:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;new_textstr = compress(textstr,,"kw");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;Thank you for response.&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2019 10:52:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delete-text-on-the-left-before-a-blank-line-kw/m-p/560434#M10461</guid>
      <dc:creator>SIgnificatif</dc:creator>
      <dc:date>2019-05-21T10:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: Delete text on the left before a blank line (kw)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delete-text-on-the-left-before-a-blank-line-kw/m-p/560483#M10466</link>
      <description>&lt;P&gt;Can you provide a better example?&amp;nbsp; Did you run your sample program?&amp;nbsp; I don't think it does what you expect.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to remove the characters before a "marker" in a character variable just find its location and use SUBSTR().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;loc = index(string,'|');
if loc then string=substr(string,loc);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 May 2019 13:13:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delete-text-on-the-left-before-a-blank-line-kw/m-p/560483#M10466</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-21T13:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: Delete text on the left before a blank line (kw)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delete-text-on-the-left-before-a-blank-line-kw/m-p/560487#M10468</link>
      <description>Thank you for the response,&lt;BR /&gt;I need the new line marker, so the text before the new line will be removed ( remove left side from that marker ) , I provided the example with | , because I don't have another example, also how to remove multiple new lines ( and text between them) and keep the last row at the end.</description>
      <pubDate>Tue, 21 May 2019 13:21:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delete-text-on-the-left-before-a-blank-line-kw/m-p/560487#M10468</guid>
      <dc:creator>SIgnificatif</dc:creator>
      <dc:date>2019-05-21T13:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: Delete text on the left before a blank line (kw)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delete-text-on-the-left-before-a-blank-line-kw/m-p/560498#M10471</link>
      <description>&lt;P&gt;I still don't get the requirement. Are you somehow trying to treat an entire text file as if it was the value of a single variable?&lt;/P&gt;
&lt;P&gt;Normally when you read a text file each row in the file becomes a separate observation in your dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have the data already in a SAS dataset?&amp;nbsp; So does that mean you have some variable that contains literal linefeed characters ('0A'x) embedded in with the other characters?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or are you trying to read the text file?&amp;nbsp; If you are trying to read the text file what data structure are you trying to create from it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or are you just trying to transform one text file into another text file?&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2019 13:45:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delete-text-on-the-left-before-a-blank-line-kw/m-p/560498#M10471</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-21T13:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: Delete text on the left before a blank line (kw)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delete-text-on-the-left-before-a-blank-line-kw/m-p/560794#M10498</link>
      <description>&lt;P&gt;Hi.&lt;BR /&gt;&lt;BR /&gt;Thank you for your quick response,&lt;BR /&gt;&lt;BR /&gt;I'll make it easier , it's not a column text, jsut plain text..., read from a database.&lt;BR /&gt;I would like to remove all&amp;nbsp;&lt;SPAN&gt;('0A'x) and text before the last line of strings, sort of :&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;Text text text Text text text Text text text 

Text text text Text text text Text text text 
Text text text Text text text Text text text 
Text text text Text text text Text text text 

Text text text Text text text Text text text 


&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Text text text Text text text Text text text&lt;/STRONG&gt; &lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Only text in red and bold ( last line should remain)&lt;BR /&gt;Hope this helps &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2019 12:10:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delete-text-on-the-left-before-a-blank-line-kw/m-p/560794#M10498</guid>
      <dc:creator>SIgnificatif</dc:creator>
      <dc:date>2019-05-22T12:10:09Z</dc:date>
    </item>
    <item>
      <title>Re: Delete text on the left before a blank line (kw)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delete-text-on-the-left-before-a-blank-line-kw/m-p/560815#M10503</link>
      <description>&lt;P&gt;Still makes no sense, but it sounds like you have character variable with embedded linefeeds.&amp;nbsp; You can just treat the linefeeds as delimiters.&lt;/P&gt;
&lt;P&gt;Let's make an example dataset.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  mytext=catx('0A'x,'line one','line two','line three');
run;

data want;
  set have;
  newvar=scan(mytext,-1,'0A'x);
run;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 338px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29692iF3A1F94CF146EB46/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2019 12:55:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delete-text-on-the-left-before-a-blank-line-kw/m-p/560815#M10503</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-22T12:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: Delete text on the left before a blank line (kw)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delete-text-on-the-left-before-a-blank-line-kw/m-p/560817#M10504</link>
      <description>Thank you for the message,&lt;BR /&gt;I will add that : I have one input variable, I'm looking to keep only the last line of text in it.&lt;BR /&gt;&lt;BR /&gt;1) I don't know the number of lines , it's *PLAIN TEXT*&lt;BR /&gt;2) I don't know the number of '0A'x in the variable&lt;BR /&gt;3) How to treat lines of text ( plain text) as a delimiter ? ( it's not about rows and columns, but plain text)&lt;BR /&gt;&lt;BR /&gt;Thank you for response.&lt;BR /&gt;&lt;BR /&gt;Sincerely.</description>
      <pubDate>Wed, 22 May 2019 13:03:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delete-text-on-the-left-before-a-blank-line-kw/m-p/560817#M10504</guid>
      <dc:creator>SIgnificatif</dc:creator>
      <dc:date>2019-05-22T13:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: Delete text on the left before a blank line (kw)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delete-text-on-the-left-before-a-blank-line-kw/m-p/560825#M10507</link>
      <description>&lt;P&gt;Show what you have.&amp;nbsp; If it is a FILE the show a few lines of the file.&lt;/P&gt;
&lt;P&gt;If it is character strings in a dataset then show the proc contents for the dataset and proc print for a few lines.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show what you want as the result of processing your example input. Again if you want a FILE out then show the file you want. If it is a dataset that show the dataset you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example if you have what you posted in example in a FILE named 'have.txt' and you want to write just the last line to a file named 'want.txt' then just run this trivial data step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile 'have.txt' end=eof;
  file 'want.txt';
  input;
  if eof then put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;If the rules for which lines to write are more complex then explain them.&amp;nbsp; Do you want to write just the first line after a blank line? after two blank lines in a row?&amp;nbsp; All lines after two blank lines until the next blank line (basically selecting a paragraph?)&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2019 13:28:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delete-text-on-the-left-before-a-blank-line-kw/m-p/560825#M10507</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-22T13:28:06Z</dc:date>
    </item>
    <item>
      <title>Re: Delete text on the left before a blank line (kw)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delete-text-on-the-left-before-a-blank-line-kw/m-p/560881#M10517</link>
      <description>Thank you for response Dear Tom, but i'm not using the infile for this one, I'm directly using the variable, for instance :&lt;BR /&gt;sometext=.....blablaba</description>
      <pubDate>Wed, 22 May 2019 15:21:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delete-text-on-the-left-before-a-blank-line-kw/m-p/560881#M10517</guid>
      <dc:creator>SIgnificatif</dc:creator>
      <dc:date>2019-05-22T15:21:22Z</dc:date>
    </item>
    <item>
      <title>Re: Delete text on the left before a blank line (kw)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delete-text-on-the-left-before-a-blank-line-kw/m-p/560884#M10519</link>
      <description>&lt;P&gt;Show your HAVE dataset. Something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  row+1;
  input line $char80.;
cards;
Text text text Text text text Text text text 

Text text text Text text text Text text text 
Text text text Text text text Text text text 
Text text text Text text text Text text text 

Text text text Text text text Text text text 


Text text text Text text text Text text text
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The explain your logic.&amp;nbsp; In the post with those lines of data you asked to only get the last row.&lt;/P&gt;
&lt;P&gt;Why the last row?&amp;nbsp; Is it because it is the last row?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have end=eof;
  by row;
  if eof;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is it because it follows two blank lines?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have end=eof;
  if _n_&amp;gt;2 and ' '^= line and ' '=lag(line) and ' '=lag2(line);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or do you need something more complex? If so then provide examples that demonstrate the complexity you need to solve.&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2019 15:39:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delete-text-on-the-left-before-a-blank-line-kw/m-p/560884#M10519</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-22T15:39:11Z</dc:date>
    </item>
    <item>
      <title>Re: Delete text on the left before a blank line (kw)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delete-text-on-the-left-before-a-blank-line-kw/m-p/563252#M10871</link>
      <description>&lt;P&gt;Hi Dear Tom.&lt;BR /&gt;Sorry for the late reply, it's almost exactly as mentioned in the last answer ( EOF and lag method) , but i found that there are some lines that are longer, and wanted to precise if it's possible to select the last 'paragrpah' and not the last line ? thank you again.&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; have&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  row&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt; line &lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;char80&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token keyword"&gt;cards&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;SPAN class="token data string"&gt;Text text text Text text text Text text text 

Text text text Text text text Text text text 
Text text text Text text text Text text text 
Text text text Text text text Text text text 

Text text text Text text text Text text text 


&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Text text text Text text text Text text text&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;text text text.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2019 13:22:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delete-text-on-the-left-before-a-blank-line-kw/m-p/563252#M10871</guid>
      <dc:creator>SIgnificatif</dc:creator>
      <dc:date>2019-06-03T13:22:09Z</dc:date>
    </item>
    <item>
      <title>Re: Delete text on the left before a blank line (kw)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delete-text-on-the-left-before-a-blank-line-kw/m-p/563259#M10872</link>
      <description>&lt;P&gt;Sounds like you might want to number the paragraphs?&lt;/P&gt;
&lt;P&gt;So assume you already read the data into dataset named HAVE and the lines of text appear in the variable LINE.&amp;nbsp; Here is a way to assign a new number to each paragraph.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data paragraphs;
  set have;
  if line ne ' ' and lag(line)=' ' then paragraph+1;
run;  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The idea is that you will increase the paragraph number when you are on the first non-blank line.&amp;nbsp; Using the sum statement will cause the paragraph variable to be initialized to zero and retain its value across iterations of the data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you also need to keep track of double blank lines?&amp;nbsp; Or does know which lines below to which paragraph solve your problem?&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2019 14:15:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delete-text-on-the-left-before-a-blank-line-kw/m-p/563259#M10872</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-03T14:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: Delete text on the left before a blank line (kw)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delete-text-on-the-left-before-a-blank-line-kw/m-p/563274#M10874</link>
      <description>&lt;P&gt;Thx ! that's great, yes I need to track the &lt;STRONG&gt;last double blank line&lt;/STRONG&gt;, and how to 'combine' the last paragrpah to make it look like 1 text and not 2 separated lines ?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2019 14:45:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delete-text-on-the-left-before-a-blank-line-kw/m-p/563274#M10874</guid>
      <dc:creator>SIgnificatif</dc:creator>
      <dc:date>2019-06-03T14:45:07Z</dc:date>
    </item>
  </channel>
</rss>

