<?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 trouble with the index function when parsing a character variable in the same data step in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/trouble-with-the-index-function-when-parsing-a-character/m-p/551765#M9046</link>
    <description>&lt;P&gt;I cannot pass the variable as the source argument in the index function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA TEST;
INPUT NAME $20.;
CARDS;
LARS
ARNE
TOM
;
RUN;

PROC SQL;
SELECT STRIP(NAME) INTO :NOM SEPARATED BY " "
FROM TEST;
QUIT;

DATA TEST2;
FORMAT WORD CONT $200.;
DO I=1 TO 3 UNTIL(CONT="");
WORD=SCAN(SYMGET('NOM'),I, " ");
CONT=SCAN(SYMGET('NOM'),I+1, " ");
MACRO_VAR=SYMGET('NOM');
HELP="'" || strip(WORD) || "'";
NOK=INDEX(SYMGET('NOM'), STRIP(HELP));
OK=INDEX(SYMGET('NOM'), 'ARNE');
OUTPUT;
END;
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 17 Apr 2019 15:10:58 GMT</pubDate>
    <dc:creator>acordes</dc:creator>
    <dc:date>2019-04-17T15:10:58Z</dc:date>
    <item>
      <title>trouble with the index function when parsing a character variable in the same data step</title>
      <link>https://communities.sas.com/t5/New-SAS-User/trouble-with-the-index-function-when-parsing-a-character/m-p/551765#M9046</link>
      <description>&lt;P&gt;I cannot pass the variable as the source argument in the index function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA TEST;
INPUT NAME $20.;
CARDS;
LARS
ARNE
TOM
;
RUN;

PROC SQL;
SELECT STRIP(NAME) INTO :NOM SEPARATED BY " "
FROM TEST;
QUIT;

DATA TEST2;
FORMAT WORD CONT $200.;
DO I=1 TO 3 UNTIL(CONT="");
WORD=SCAN(SYMGET('NOM'),I, " ");
CONT=SCAN(SYMGET('NOM'),I+1, " ");
MACRO_VAR=SYMGET('NOM');
HELP="'" || strip(WORD) || "'";
NOK=INDEX(SYMGET('NOM'), STRIP(HELP));
OK=INDEX(SYMGET('NOM'), 'ARNE');
OUTPUT;
END;
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Apr 2019 15:10:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/trouble-with-the-index-function-when-parsing-a-character/m-p/551765#M9046</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2019-04-17T15:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: trouble with the index function when parsing a character variable in the same data step</title>
      <link>https://communities.sas.com/t5/New-SAS-User/trouble-with-the-index-function-when-parsing-a-character/m-p/551775#M9048</link>
      <description>&lt;P&gt;Please describe what you are attempting to do. The code runs but I have no idea what the output should be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And your index is likely failing because you have quotes around the value in "HELP" so there isn't a match in the string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And you really don't need to keep calling symget:&lt;/P&gt;
&lt;PRE&gt;DATA TEST2;
   FORMAT WORD CONT $200.;
   DO I=1 TO 3 UNTIL(CONT="");
      WORD=SCAN("&amp;amp;nom.",I, " ");
      CONT=SCAN("&amp;amp;nom.",I+1, " ");
      MACRO_VAR="&amp;amp;nom.";
      HELP="'" || strip(WORD) || "'";
      NOK=INDEX("&amp;amp;nom.",strip(WORD));
      OK=INDEX("&amp;amp;nom.", 'ARNE');
      OUTPUT;
   END;
RUN;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Apr 2019 15:35:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/trouble-with-the-index-function-when-parsing-a-character/m-p/551775#M9048</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-17T15:35:46Z</dc:date>
    </item>
  </channel>
</rss>

