<?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 How do I use Input @'string' right to left? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-Input-string-right-to-left/m-p/560247#M156618</link>
    <description>&lt;P&gt;Is there anyway to use an input&amp;nbsp;@ statement and have it scan text right to left instead of left to right?&amp;nbsp; I have the following code&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data mydata;&lt;BR /&gt;infile _filename_ truncover scanover;&lt;BR /&gt;input @'string' variable $X.&lt;BR /&gt;run;&lt;/PRE&gt;&lt;P&gt;and am trying to extract X characters before "string," not after, and for the life of me, I cannot figure it out.&amp;nbsp; My program as a whole works&amp;nbsp;&lt;EM&gt;if&lt;/EM&gt; I wanted to extract X characters&amp;nbsp;&lt;EM&gt;after&lt;/EM&gt; the string "text" was found.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 20 May 2019 18:44:48 GMT</pubDate>
    <dc:creator>phdibart</dc:creator>
    <dc:date>2019-05-20T18:44:48Z</dc:date>
    <item>
      <title>How do I use Input @'string' right to left?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-Input-string-right-to-left/m-p/560247#M156618</link>
      <description>&lt;P&gt;Is there anyway to use an input&amp;nbsp;@ statement and have it scan text right to left instead of left to right?&amp;nbsp; I have the following code&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data mydata;&lt;BR /&gt;infile _filename_ truncover scanover;&lt;BR /&gt;input @'string' variable $X.&lt;BR /&gt;run;&lt;/PRE&gt;&lt;P&gt;and am trying to extract X characters before "string," not after, and for the life of me, I cannot figure it out.&amp;nbsp; My program as a whole works&amp;nbsp;&lt;EM&gt;if&lt;/EM&gt; I wanted to extract X characters&amp;nbsp;&lt;EM&gt;after&lt;/EM&gt; the string "text" was found.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 18:44:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-Input-string-right-to-left/m-p/560247#M156618</guid>
      <dc:creator>phdibart</dc:creator>
      <dc:date>2019-05-20T18:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use Input @'string' right to left?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-Input-string-right-to-left/m-p/560251#M156621</link>
      <description>&lt;P&gt;You cannot use TRUNCOVER and SCANOVER at the same time.&amp;nbsp; I suspect that the last one mentioned is what SAS will use.&lt;/P&gt;
&lt;P&gt;Did you try cursor movement commands?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mydata;
  infile cards ;
  input @'string' +(-16) variable $10. ;
cards;
This line has string in middle
This line has it at the end string 
Short string
does not appear at all
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You might need to play around to deal with boundary conditions.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mydata;
  infile cards column=cc ;
  input @'string' @ ;
  found=cc;
  offset = min(cc - length('string') - 10 , cc);
  input @offset variable $10. ;
cards;
This line has string in middle
This line has it at the end string 
Short string
does not appear at all
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 19:06:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-Input-string-right-to-left/m-p/560251#M156621</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-20T19:06:50Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use Input @'string' right to left?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-Input-string-right-to-left/m-p/560252#M156622</link>
      <description>&lt;P&gt;Check out example 7 -&amp;nbsp;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000146292.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000146292.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 19:04:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-Input-string-right-to-left/m-p/560252#M156622</guid>
      <dc:creator>noling</dc:creator>
      <dc:date>2019-05-20T19:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use Input @'string' right to left?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-Input-string-right-to-left/m-p/560499#M156751</link>
      <description>&lt;P&gt;If you have multiple 'string' in a row, could use PRXNEXT().&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mydata;
infile cards truncover;
input;
p=prxmatch('/.{4}(?=string)/i',_infile_);
if p=0 then p=length(_infile_)+1;
want=substrn(_infile_,p,4);
cards;
This line has string in middle
This line has it at the end string 
Short string
does not appear at all
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 May 2019 13:45:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-Input-string-right-to-left/m-p/560499#M156751</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-05-21T13:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use Input @'string' right to left?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-Input-string-right-to-left/m-p/560574#M156788</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/274623"&gt;@phdibart&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have always found input with @'string' too inflexible compared to reading the whole line into SAS. Using the automatic variable _infile_ is easier, because you can use the full arsenal of SAS string functions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This example takes the last 10 characters before 'string' regardless of blanks etc, but it would be just as easy to search for 'string' as a word and extract the last word before that, or whatever would be needed in your case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;File content:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;This line has string in middle&lt;BR /&gt;This line has it at the end string &lt;BR /&gt;Short string&lt;BR /&gt;does not appear at all&lt;BR /&gt;thisisalongline1234567890stringandmore&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let string = string;
data want (drop=pos);
	infile 'c:\temp\testfile.txt';
	input;
	pos = find(_infile_,"&amp;amp;string",'i');
	if pos &amp;gt; 10 then var = substr(_infile_,pos-10,10);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2019 16:43:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-Input-string-right-to-left/m-p/560574#M156788</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2019-05-21T16:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use Input @'string' right to left?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-Input-string-right-to-left/m-p/560592#M156797</link>
      <description>&lt;P&gt;:edit:&amp;nbsp; I answered my question.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you all for your suggestions.&amp;nbsp; The following code worked.&lt;/P&gt;&lt;PRE&gt;%let lltract=32.3861,-99.7583;
%let llmsa=32.4101,-99.8114;

filename google url "http://maps.google.com/maps?daddr=&amp;amp;llmsa.%nrstr(&amp;amp;saddr)=&amp;amp;lltract";

data drive (drop = m);
infile google scanover;
llmsa = symget('llmsa');
lltract = symget('lltract');
m = -13;
input @'miles\"'+m miles $34.;
run;

filename google clear;&lt;/PRE&gt;&lt;P&gt;You can use truncover with scanover.&amp;nbsp; See example #3.&amp;nbsp;&amp;nbsp;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000146932.htm" target="_blank" rel="noopener"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000146932.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2019 23:08:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-use-Input-string-right-to-left/m-p/560592#M156797</guid>
      <dc:creator>phdibart</dc:creator>
      <dc:date>2019-05-21T23:08:22Z</dc:date>
    </item>
  </channel>
</rss>

