<?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: What does this SAS code mean? Index... in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/What-does-this-SAS-code-mean-Index/m-p/826238#M326358</link>
    <description>&lt;P&gt;Index function:&amp;nbsp;&lt;SPAN&gt;Searches a character expression for a &lt;STRONG&gt;string of characters&lt;/STRONG&gt;, and &lt;STRONG&gt;returns the position of the string's first character for the first occurrence of the string&lt;/STRONG&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;From your example, variable1 appears numeric. So not sure why it was being used. Or perhaps being used to&amp;nbsp;convert a character variable to numeric and&amp;nbsp;checking for a specific&amp;nbsp;condition that may need to be&amp;nbsp;excluded?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If it's in a conditional&amp;nbsp;statement, anything above 0 is considered TRUE so the remaining code in your condition will execute if that character&amp;nbsp;is found in the string.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.2/lefunctionsref/n0vxokxhv8lr84n10nrbnzp7gnba.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.2/lefunctionsref/n0vxokxhv8lr84n10nrbnzp7gnba.htm&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/430566"&gt;@Daen&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;What does&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;if index(variable1,'¤') &amp;gt; 0&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;mean?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I do the below, I get values of 0, 8 and 9 for different values of variable1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;testvar = index(variable1,'¤') &amp;gt; 0;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 29 Jul 2022 22:26:00 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2022-07-29T22:26:00Z</dc:date>
    <item>
      <title>What does this SAS code mean? Index...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-does-this-SAS-code-mean-Index/m-p/826230#M326352</link>
      <description>&lt;P&gt;What does&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;if index(variable1,'¤') &amp;gt; 0&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;mean?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I do the below, I get values of 0, 8 and 9 for different values of variable1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;testvar = index(variable1,'¤') &amp;gt; 0;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jul 2022 21:49:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-does-this-SAS-code-mean-Index/m-p/826230#M326352</guid>
      <dc:creator>Daen</dc:creator>
      <dc:date>2022-07-29T21:49:38Z</dc:date>
    </item>
    <item>
      <title>Re: What does this SAS code mean? Index...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-does-this-SAS-code-mean-Index/m-p/826232#M326354</link>
      <description>&lt;P&gt;I meant, I tested the below and got values of 0, 8 and 9 for different values of variable1 with values of 0.6057, 0.0107 and 1E-7 respectively.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;testvar = index(variable1,'¤');&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jul 2022 21:52:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-does-this-SAS-code-mean-Index/m-p/826232#M326354</guid>
      <dc:creator>Daen</dc:creator>
      <dc:date>2022-07-29T21:52:59Z</dc:date>
    </item>
    <item>
      <title>Re: What does this SAS code mean? Index...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-does-this-SAS-code-mean-Index/m-p/826238#M326358</link>
      <description>&lt;P&gt;Index function:&amp;nbsp;&lt;SPAN&gt;Searches a character expression for a &lt;STRONG&gt;string of characters&lt;/STRONG&gt;, and &lt;STRONG&gt;returns the position of the string's first character for the first occurrence of the string&lt;/STRONG&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;From your example, variable1 appears numeric. So not sure why it was being used. Or perhaps being used to&amp;nbsp;convert a character variable to numeric and&amp;nbsp;checking for a specific&amp;nbsp;condition that may need to be&amp;nbsp;excluded?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If it's in a conditional&amp;nbsp;statement, anything above 0 is considered TRUE so the remaining code in your condition will execute if that character&amp;nbsp;is found in the string.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.2/lefunctionsref/n0vxokxhv8lr84n10nrbnzp7gnba.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.2/lefunctionsref/n0vxokxhv8lr84n10nrbnzp7gnba.htm&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/430566"&gt;@Daen&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;What does&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;if index(variable1,'¤') &amp;gt; 0&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;mean?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I do the below, I get values of 0, 8 and 9 for different values of variable1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;testvar = index(variable1,'¤') &amp;gt; 0;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jul 2022 22:26:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-does-this-SAS-code-mean-Index/m-p/826238#M326358</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-07-29T22:26:00Z</dc:date>
    </item>
    <item>
      <title>Re: What does this SAS code mean? Index...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-does-this-SAS-code-mean-Index/m-p/826243#M326363</link>
      <description>&lt;P&gt;Any idea what that symbol&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;'¤'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;means?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Variable1 is numeric. I thought that symbol might mean, check the number of decimal places, but that didn't seem right with the values obtained?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jul 2022 22:50:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-does-this-SAS-code-mean-Index/m-p/826243#M326363</guid>
      <dc:creator>Daen</dc:creator>
      <dc:date>2022-07-29T22:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: What does this SAS code mean? Index...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-does-this-SAS-code-mean-Index/m-p/826246#M326366</link>
      <description>&lt;P&gt;Seems like a symbol to me, possibly the character for an invisible white space character or something used as delimiter? &lt;A href="https://unicodelookup.com/#¤/1" target="_self"&gt;Currency symbol?&lt;/A&gt; What does the rest of the code look like? With just that line it's very broad guesses.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My random guess is:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Data was imported using proc import&lt;/LI&gt;
&lt;LI&gt;this variable was text at some point otherwise using INDEX makes no sense&lt;/LI&gt;
&lt;LI&gt;this was a step to clean it up the field and convert it to number&amp;nbsp;&lt;/LI&gt;
&lt;/UL&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/430566"&gt;@Daen&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Any idea what that symbol&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;'¤'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;means?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Variable1 is numeric. I thought that symbol might mean, check the number of decimal places, but that didn't seem right with the values obtained?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Jul 2022 00:15:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-does-this-SAS-code-mean-Index/m-p/826246#M326366</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-07-30T00:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: What does this SAS code mean? Index...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-does-this-SAS-code-mean-Index/m-p/826253#M326370</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/430566"&gt;@Daen&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;What does&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;if index(variable1,'¤') &amp;gt; 0&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;mean?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I do the below, I get values of 0, 8 and 9 for different values of variable1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;testvar = index(variable1,'¤') &amp;gt; 0;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;There is no way that TESTVAR could ever get a value other than 0 or 1 from that statement.&amp;nbsp; SAS evaluates boolean expressions. like your test if the result of the INDEX() function call is larger than 0, as 1 when TRUE and 0 when FALSE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &lt;A href="https://documentation.sas.com/doc/en/vdmmlcdc/8.1/lefunctionsref/n0vxokxhv8lr84n10nrbnzp7gnba.htm#:~:text=The%20INDEX%20function%20searches%20source,returns%20a%20value%20of%200." target="_self"&gt;INDEX() function&lt;/A&gt; returns the location in the string string of the start of the second string. If it is not found it returns zero.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The character you posted is the character A4 in &lt;A href="https://cs.stanford.edu/people/miles/iso8859.html" target="_self"&gt;Latin1 encoding&lt;/A&gt;.&lt;/P&gt;
&lt;TABLE border="1" cellspacing="0" cellpadding="3"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;TT&gt;&amp;amp;#164;&lt;/TT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;TT&gt;A4&lt;/TT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;TT&gt;¤&lt;/TT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;TT&gt;&amp;amp;curren;&lt;/TT&gt;&lt;/TD&gt;
&lt;TD&gt;general currency sign&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;But in EBCDIC it is a lower case U.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If variable1 is numeric you should get notes about SAS converting it to a string so it could be passed to the INDEX() function and the value of TESTVAR will always be set to zero since the string SAS will create from a numeric variable will never contain that character, whatever it is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS When coding string literals that have characters that are not between a space and tilda in the ASCII code sequence you might want to use hex literals instead to avoid issues when the encoding changes.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;testvar = index(variable1,'A4'x) &amp;gt; 0;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Jul 2022 03:42:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-does-this-SAS-code-mean-Index/m-p/826253#M326370</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-30T03:42:09Z</dc:date>
    </item>
  </channel>
</rss>

