<?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 search for a string in double quotes in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/how-to-search-for-a-string-in-double-quotes/m-p/828997#M35487</link>
    <description>&lt;P&gt;Here's a theory as to the cause ... it should be easy for you to test.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When your INPUT statement ends, it releases the current line of raw data.&amp;nbsp; That updates the value of _INFILE_.&amp;nbsp; So make a small change to your program to hold on to the current line of raw data just a little bit longer:&amp;nbsp; Where you have:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;change it to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input @;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 17 Aug 2022 11:42:32 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2022-08-17T11:42:32Z</dc:date>
    <item>
      <title>how to search for a string in double quotes</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-search-for-a-string-in-double-quotes/m-p/828987#M35484</link>
      <description>&lt;P&gt;Hello Team ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;we are having below text in the end of&amp;nbsp; XML file&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;lt;link rel="next" href="&lt;A href="http://spappfarm.opintra.fi/iapps/testsite_uat/_api/Web/Lists/getByTitle('test%20test%20test%20test')/items?%24skiptoken=Paged%3dTRUE%26p_ID%3d1082&amp;amp;amp;=1000" target="_blank"&gt;http://spappfarm.opintra.fi/iapps/testsite_uat/_api/Web/Lists/getByTitle('test%20test%20test%20test')/items?%24skiptoken=Paged%3dTRUE%26p_ID%3d1082&amp;amp;amp;=1000&lt;/A&gt;" /&amp;gt;&amp;lt;/feed&amp;gt;);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%macro GetFileByServerRelativeUrl (out_param=);
		%global &amp;amp;out_param. test1;
		%let &amp;amp;out_param.=;
		data _null_;
		length text $32767;
        infile "/out_countryrisk_fi.txt" DSD DLM="09"x ;
	 	input;
		test1=index( _infile_,'next');
		put 'this is to test value ' test1 ;
		call symputx("&amp;amp;out_param.", text);
      	run;
%put  macro variable &amp;amp;out_param. created with value &amp;amp;&amp;amp;&amp;amp;out_param. ;
		
%mend;

 %GetFileByServerRelativeUrl ( out_param=ServerUrl_new);
&lt;/PRE&gt;
&lt;P&gt;1. am try to search for word 'next' in the XML&amp;nbsp; using&lt;/P&gt;
&lt;P&gt;&amp;nbsp;test1=index( _infile_,'next');&amp;nbsp; where am getting '0' as output&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. how to read the text only in double quotes after the word next in above string&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 10:22:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-search-for-a-string-in-double-quotes/m-p/828987#M35484</guid>
      <dc:creator>learn_SAS_23</dc:creator>
      <dc:date>2022-08-17T10:22:09Z</dc:date>
    </item>
    <item>
      <title>Re: how to search for a string in double quotes</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-search-for-a-string-in-double-quotes/m-p/828991#M35485</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your use of INDEX() looks fine to me, e.g. below works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_ ;
  string="&amp;lt;link rel=""next"" href=""http://spappfarm.opintra.fi/iapps/testsite_uat/_api/Web/Lists/getByTitle('test%20test%20test%20test'..."" /&amp;gt;&amp;lt;/feed&amp;gt;);" ;
  test1=index(string,'next');
  put string= test1=;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Note that your XML file likely has multiple lines, and this will be checking every line to see if it has the string "next" on in it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To debug, I suggest you change your PUT statement to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;put 'this is to test value ' test1= _infile_ ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That should let you check that the _infile_ variable has the value you intend.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 11:05:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-search-for-a-string-in-double-quotes/m-p/828991#M35485</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-08-17T11:05:25Z</dc:date>
    </item>
    <item>
      <title>Re: how to search for a string in double quotes</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-search-for-a-string-in-double-quotes/m-p/828995#M35486</link>
      <description>thanks for quick reply,&lt;BR /&gt;is there any way to double quote whole text in a file , as i observe you enclosed the double quoted string in double quote like this ""next""</description>
      <pubDate>Wed, 17 Aug 2022 11:31:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-search-for-a-string-in-double-quotes/m-p/828995#M35486</guid>
      <dc:creator>learn_SAS_23</dc:creator>
      <dc:date>2022-08-17T11:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: how to search for a string in double quotes</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-search-for-a-string-in-double-quotes/m-p/828997#M35487</link>
      <description>&lt;P&gt;Here's a theory as to the cause ... it should be easy for you to test.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When your INPUT statement ends, it releases the current line of raw data.&amp;nbsp; That updates the value of _INFILE_.&amp;nbsp; So make a small change to your program to hold on to the current line of raw data just a little bit longer:&amp;nbsp; Where you have:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;change it to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input @;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Aug 2022 11:42:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-search-for-a-string-in-double-quotes/m-p/828997#M35487</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2022-08-17T11:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: how to search for a string in double quotes</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-search-for-a-string-in-double-quotes/m-p/828998#M35488</link>
      <description>Hi, you don't need to double quote the values you read from the text file.  I had to do it because I was using the string on an assignment statement, so I used double quote marks to define the string, and then inside the string used double double quotes.  Put if you run my code, you will see the PUT statement shows that the value of STRING does not have double double quotes in it.  Because the assignment statement translates ""next"" to "next".</description>
      <pubDate>Wed, 17 Aug 2022 11:50:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-search-for-a-string-in-double-quotes/m-p/828998#M35488</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-08-17T11:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to search for a string in double quotes</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-search-for-a-string-in-double-quotes/m-p/829001#M35489</link>
      <description>&lt;P&gt;Your original code works for me.&amp;nbsp; Here is an example where I write a file, and then read in the file using your original code.&amp;nbsp; I added a PUT statement to show the value of _infile_.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*generate an input file;
data _null_ ;
  file "Q:\junk\foo.txt" ;
  put "&amp;lt;link rel=""next"" href=""http://spappfarm.opintra.fi/iapps/testsite_uat/_api/Web/Lists/getByTitle('test%20test%20test%20test'..."" /&amp;gt;&amp;lt;/feed&amp;gt;);" ;
  put "hello world" ;
run ; 


*Read in the file ;
data _null_;
  infile "Q:\junk\foo.txt" DSD DLM="09"x ;
  input;
  test1=index( _infile_,'next');
  put "the value of _infile_ is:"  _infile_  ;
  put 'this is to test value ' test1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log is:&lt;/P&gt;
&lt;PRE&gt;10   *Read in the file ;
11   data _null_;
12     infile "Q:\junk\foo.txt" DSD DLM="09"x ;
13     input;
14     test1=index( _infile_,'next');
15     put "the value of _infile_ is:"  _infile_  ;
16     put 'this is to test value ' test1;
17   run;

NOTE: The infile "Q:\junk\foo.txt" is:
      Filename=Q:\junk\foo.txt,
      RECFM=V,LRECL=32767,File Size (bytes)=154,
      Last Modified=17Aug2022:08:03:28,
      Create Time=17Aug2022:07:54:47

the value of _infile_ is:
&amp;lt;link rel="next" href="http://spappfarm.opintra.fi/iapps/testsite_uat/_api/Web/Lists/getByTitle('test%
20test%20test%20test'..." /&amp;gt;&amp;lt;/feed&amp;gt;);
this is to test value 12
the value of _infile_ is:hello world
this is to test value 0
NOTE: 2 records were read from the infile "Q:\junk\foo.txt".
      The minimum record length was 11.
      The maximum record length was 139.
&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Aug 2022 12:04:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-search-for-a-string-in-double-quotes/m-p/829001#M35489</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-08-17T12:04:13Z</dc:date>
    </item>
    <item>
      <title>Re: how to search for a string in double quotes</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-search-for-a-string-in-double-quotes/m-p/829034#M35490</link>
      <description>&lt;P&gt;Are you just looking for the HREF= values that appear after the NEXT string?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  infile "/out_countryrisk_fi.txt" DSD DLM='&amp;lt;= &amp;gt;' ;
  input @'"next"' @ '"href"=' text :$32767. @@ ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Aug 2022 14:20:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-search-for-a-string-in-double-quotes/m-p/829034#M35490</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-08-17T14:20:25Z</dc:date>
    </item>
    <item>
      <title>Re: how to search for a string in double quotes</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-search-for-a-string-in-double-quotes/m-p/829155#M35498</link>
      <description>&lt;P&gt;Thanks every one for all your inputs ,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;from this i could able to analyse that the input file am reading is more than&amp;nbsp;&lt;SPAN&gt;32767 , so the lines having the text (next) are truncated .&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Here is solution , where am reading the input file morethan 32767 untill end of the file and searching for the string 'next' using find and finally extracting the text in href which are enclosed in doublequotes.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data Test_dataset;&lt;BR /&gt;infile " /out_test.txt" lrecl=32767 recfm=f truncover;&lt;BR /&gt;input @1 myline $CHAR32767.; &lt;BR /&gt;put "the value of _infile_ is:" _infile_ ;&lt;BR /&gt;test1=find( _infile_,'next');&lt;BR /&gt;text=scan(substr(_infile_, find( _infile_,'next')+11),1,"""");&lt;BR /&gt;put 'this is to test value ' text;&lt;BR /&gt;run;&lt;/SPAN&gt;&lt;/P&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>Thu, 18 Aug 2022 07:38:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-search-for-a-string-in-double-quotes/m-p/829155#M35498</guid>
      <dc:creator>learn_SAS_23</dc:creator>
      <dc:date>2022-08-18T07:38:05Z</dc:date>
    </item>
  </channel>
</rss>

