<?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: Do Not Understand PROC FCMP for characters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Do-Not-Understand-PROC-FCMP-for-characters/m-p/779989#M248479</link>
    <description>&lt;P&gt;Solved!&lt;/P&gt;&lt;P&gt;Thank you, this solution worked.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Nov 2021 14:53:51 GMT</pubDate>
    <dc:creator>SAS4FUN1</dc:creator>
    <dc:date>2021-11-12T14:53:51Z</dc:date>
    <item>
      <title>Do Not Understand PROC FCMP for characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Not-Understand-PROC-FCMP-for-characters/m-p/779865#M248432</link>
      <description>&lt;P&gt;Studying for the SAS Advanced Cert exam and came across this problem in a practice exam. I do not understand why my PROC FCMP function does not return the same results as the same code in the data step. It only returns the first letter of the second word.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data testscandata;&lt;BR /&gt;infile cards dsd dlm='|';&lt;BR /&gt;input one $ two $ one_two $;&lt;BR /&gt;datalines;&lt;BR /&gt;one|two|one two&lt;BR /&gt;one|two|one two&lt;BR /&gt;one|two|one two&lt;BR /&gt;one|two|one two&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;PROC FCMP OUTLIB=WORK.FUNCTIONS.DEV;&lt;BR /&gt;FUNCTION scantx (STRING $) $ 100;&lt;BR /&gt;SCNOUT=catx(" ",scan(STRING,2), scan(STRING,1));&lt;BR /&gt;RETURN (SCNOUT);&lt;BR /&gt;ENDSUB;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;OPTIONS CMPLIB=WORK.FUNCTIONS;&lt;/P&gt;&lt;P&gt;DATA TEST_FUNC;&lt;BR /&gt;SET WORK.testscandata;&lt;BR /&gt;two_one_func = scantx(one_two);&lt;BR /&gt;two_one_test = catx(" ",scan(one_two,2), scan(one_two,1));&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Nov 2021 22:14:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Not-Understand-PROC-FCMP-for-characters/m-p/779865#M248432</guid>
      <dc:creator>SAS4FUN1</dc:creator>
      <dc:date>2021-11-11T22:14:17Z</dc:date>
    </item>
    <item>
      <title>Re: Do Not Understand PROC FCMP for characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Not-Understand-PROC-FCMP-for-characters/m-p/779868#M248435</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Consider what the LENGTH you may have defined for the variable SCNOUT in the function might be.&lt;/P&gt;
&lt;P&gt;See what happens with&lt;/P&gt;
&lt;PRE&gt;PROC FCMP OUTLIB=WORK.FUNCTIONS.DEV;
FUNCTION scantx (STRING $) $ 100;
length scnout $ 100;
SCNOUT=catx(" ",scan(STRING,2), scan(STRING,1));
RETURN (SCNOUT);
ENDSUB;
RUN;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/398365"&gt;@SAS4FUN1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Studying for the SAS Advanced Cert exam and came across this problem in a practice exam. I do not understand why my PROC FCMP function does not return the same results as the same code in the data step. It only returns the first letter of the second word.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data testscandata;&lt;BR /&gt;infile cards dsd dlm='|';&lt;BR /&gt;input one $ two $ one_two $;&lt;BR /&gt;datalines;&lt;BR /&gt;one|two|one two&lt;BR /&gt;one|two|one two&lt;BR /&gt;one|two|one two&lt;BR /&gt;one|two|one two&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;PROC FCMP OUTLIB=WORK.FUNCTIONS.DEV;&lt;BR /&gt;FUNCTION scantx (STRING $) $ 100;&lt;BR /&gt;SCNOUT=catx(" ",scan(STRING,2), scan(STRING,1));&lt;BR /&gt;RETURN (SCNOUT);&lt;BR /&gt;ENDSUB;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;OPTIONS CMPLIB=WORK.FUNCTIONS;&lt;/P&gt;
&lt;P&gt;DATA TEST_FUNC;&lt;BR /&gt;SET WORK.testscandata;&lt;BR /&gt;two_one_func = scantx(one_two);&lt;BR /&gt;two_one_test = catx(" ",scan(one_two,2), scan(one_two,1));&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Nov 2021 22:27:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Not-Understand-PROC-FCMP-for-characters/m-p/779868#M248435</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-11-11T22:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: Do Not Understand PROC FCMP for characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Not-Understand-PROC-FCMP-for-characters/m-p/779989#M248479</link>
      <description>&lt;P&gt;Solved!&lt;/P&gt;&lt;P&gt;Thank you, this solution worked.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Nov 2021 14:53:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Not-Understand-PROC-FCMP-for-characters/m-p/779989#M248479</guid>
      <dc:creator>SAS4FUN1</dc:creator>
      <dc:date>2021-11-12T14:53:51Z</dc:date>
    </item>
  </channel>
</rss>

