<?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: PROC FCMP - Output Character Value Truncation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-FCMP-Output-Character-Value-Truncation/m-p/562843#M157727</link>
    <description>&lt;P&gt;Include your LENGTH statement in FUNCTION .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
PROC FCMP OUTLIB=WORK.FUNCTIONS.BUSREQS;


FUNCTION CLEANCOLUMNNAMES(OLD_NAME $) $ 500;
LENGTH NEW_NAME $ 500; /*&amp;lt;-- Here*/

NEW_NAME = PRXCHANGE('s/[^a-z A-Z 0-9_]/ /',-1,TRIM(LEFT(OLD_NAME)));

RETURN (NEW_NAME);

ENDSUB;

RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 31 May 2019 14:00:39 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2019-05-31T14:00:39Z</dc:date>
    <item>
      <title>PROC FCMP - Output Character Value Truncation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FCMP-Output-Character-Value-Truncation/m-p/562774#M157695</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Running SAS 9.4M5.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am looking to clean up a list of potential variable names and as a result I decided to create a custom function.&amp;nbsp; The problem is, even though I have explicitly set the length (excessively large at 500) of the resulting variable, I still max out at 20 characters and some of the data is being truncated.&amp;nbsp; I have tested the PRXCHANGE syntax in a stand alone datastep and it works as desired, however when I copy the exact syntax into FCMP the truncation occurs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following is a subset list of potential variable names:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA HAVE;
INFILE DATALINES DLM=",";
INPUT BUFFER : $200.;
DATALINES;
Policy Number
Vehicle Sequence Number
Vehicle Suffix
Vehicle Seqno - Financials
Status
;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The Proc FCMP step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC FCMP OUTLIB=WORK.FUNCTIONS.BUSREQS;

LENGTH NEW_NAME $ 500;

FUNCTION CLEANCOLUMNNAMES(OLD_NAME $) $ 500;
NEW_NAME = PRXCHANGE('s/[^a-z A-Z 0-9_]/ /',-1,TRIM(LEFT(OLD_NAME)));

RETURN (NEW_NAME);

ENDSUB;

RUN;&lt;BR /&gt;&lt;BR /&gt;OPTIONS CMPLIB = (WORK.FUNCTIONS);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Datastep using the newly created variable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA WANT;
SET HAVE;
LENGTH TEST $ 500;
TEST = CLEANCOLUMNNAMES(BUFFER);
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results showing the truncated results:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29916i626494FC2F00467B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any assistance would be greatly appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Scott&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;
&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>Fri, 31 May 2019 05:42:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FCMP-Output-Character-Value-Truncation/m-p/562774#M157695</guid>
      <dc:creator>Scott_Mitchell</dc:creator>
      <dc:date>2019-05-31T05:42:52Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FCMP - Output Character Value Truncation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FCMP-Output-Character-Value-Truncation/m-p/562843#M157727</link>
      <description>&lt;P&gt;Include your LENGTH statement in FUNCTION .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
PROC FCMP OUTLIB=WORK.FUNCTIONS.BUSREQS;


FUNCTION CLEANCOLUMNNAMES(OLD_NAME $) $ 500;
LENGTH NEW_NAME $ 500; /*&amp;lt;-- Here*/

NEW_NAME = PRXCHANGE('s/[^a-z A-Z 0-9_]/ /',-1,TRIM(LEFT(OLD_NAME)));

RETURN (NEW_NAME);

ENDSUB;

RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 31 May 2019 14:00:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FCMP-Output-Character-Value-Truncation/m-p/562843#M157727</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-05-31T14:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FCMP - Output Character Value Truncation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FCMP-Output-Character-Value-Truncation/m-p/563211#M157857</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;.&amp;nbsp; I will give this a shot tomorrow.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2019 09:49:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FCMP-Output-Character-Value-Truncation/m-p/563211#M157857</guid>
      <dc:creator>Scott_Mitchell</dc:creator>
      <dc:date>2019-06-03T09:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FCMP - Output Character Value Truncation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FCMP-Output-Character-Value-Truncation/m-p/563453#M157966</link>
      <description>Worked perfectly.  Thank you.</description>
      <pubDate>Tue, 04 Jun 2019 07:04:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FCMP-Output-Character-Value-Truncation/m-p/563453#M157966</guid>
      <dc:creator>Scott_Mitchell</dc:creator>
      <dc:date>2019-06-04T07:04:00Z</dc:date>
    </item>
  </channel>
</rss>

