<?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: Why &amp;quot;TRIM&amp;quot; and &amp;quot;VERIFY&amp;quot; functions fail to solve my problem? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372549#M89090</link>
    <description>By the way, may I ask how do you highlight the SAS keyword in the code chunk?</description>
    <pubDate>Sun, 02 Jul 2017 14:29:33 GMT</pubDate>
    <dc:creator>Zhanxiong</dc:creator>
    <dc:date>2017-07-02T14:29:33Z</dc:date>
    <item>
      <title>Why "TRIM" and "VERIFY" functions fail to solve my problem?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372474#M89059</link>
      <description>&lt;P&gt;I have a data set&amp;nbsp;&lt;FONT face="courier new,courier"&gt;good_bad&lt;/FONT&gt; created by the following data step:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data good_bad;
    input answer $40.;
    datalines;
1324AcB876acccCCC
123 456
aabbccAABBCC123123
abcde12345
invalid
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Now I want to create a new data set &lt;FONT face="courier new,courier"&gt;valid&lt;/FONT&gt; which consists of the observations from the &lt;FONT face="courier new,courier"&gt;good_bad&lt;/FONT&gt;&amp;nbsp;whose characters are from 'ABC', 'abc',&amp;nbsp;and '0123456789'. While the trailing blanks are ignored, the embedded blank should be considered invalid. Based on these requirements, I wrote a data step as follows:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data valid;
    set good_bad;
    answer = trim(upcase(answer));
    if verify(answer, 'ABC0123456789') = 0; 
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Unluckily, this program doesn't produce the output data set which consists of line 1 and line 3 of &lt;FONT face="courier new,courier"&gt;good_bad&lt;/FONT&gt;. Instead, it contains 0 rows. It seems that the TRIM function didn't remove the trailing blanks, as it was supposed to do. Can anyone help me solve this problem (by only using TRIM and VERIFY functions)? Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2017 20:00:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372474#M89059</guid>
      <dc:creator>Zhanxiong</dc:creator>
      <dc:date>2017-07-02T20:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: Why "TRIM" and "VERIFY" functions fail to solve my problem?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372476#M89061</link>
      <description>&lt;P&gt;Trim only removes spaces to the right, not the left. However, verify identifies the first invalid character, so you could use:&lt;/P&gt;
&lt;PRE&gt;data good_bad;
    input answer $40.;
    datalines;
1324AcB876acccCCC
123 456
aabbccAABBCC123123
abcde12345
invalid
;
data valid;
    set good_bad;
    answer = trim(upcase(answer));
    if length(answer) le verify(answer, 'ABC0123456789');
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2017 01:18:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372476#M89061</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-07-02T01:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: Why "TRIM" and "VERIFY" functions fail to solve my problem?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372480#M89064</link>
      <description>&lt;P&gt;Thanks. But I don't think I have leading blanks in the original ANSWER variable. Even so, I can use STRIP in place of TRIM to remove all leading and trailing blanks as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data valid;
    set good_bad;
    temp = strip(upcase(answer));
    if verify(temp, 'ABC0123456789') = 0; 
run;&lt;/PRE&gt;&lt;P&gt;However, this still gives an empty data set.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your suggested program works correctly, I am just curious about why (my simple) VERIFY statement doesn's solve the problem, even the blanks problem is properly handled in advance?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2017 01:45:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372480#M89064</guid>
      <dc:creator>Zhanxiong</dc:creator>
      <dc:date>2017-07-02T01:45:19Z</dc:date>
    </item>
    <item>
      <title>Re: Why "TRIM" and "VERIFY" functions fail to solve my problem?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372483#M89065</link>
      <description>&lt;P&gt;Depends upon where you use the trim or strip function. e.g., the following does do what you expect:&lt;/P&gt;
&lt;PRE&gt;data valid3;
    set good_bad;
    if verify(trim(upcase(answer)), 'ABC0123456789') =0;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2017 02:01:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372483#M89065</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-07-02T02:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: Why "TRIM" and "VERIFY" functions fail to solve my problem?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372486#M89066</link>
      <description>&lt;P&gt;Yes, it does!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On the other hand, why does the additional assignment statement spoil the program? To me, the working program and the previous one do not have an essential difference. Could you please explain more to me why these two are different? Thanks again.&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2017 02:16:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372486#M89066</guid>
      <dc:creator>Zhanxiong</dc:creator>
      <dc:date>2017-07-02T02:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: Why "TRIM" and "VERIFY" functions fail to solve my problem?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372487#M89067</link>
      <description>&lt;P&gt;What's the length of the two variables?&lt;BR /&gt;How does SAS treat a variable that has a longer length than then the actual values?&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2017 02:17:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372487#M89067</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-02T02:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: Why "TRIM" and "VERIFY" functions fail to solve my problem?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372488#M89068</link>
      <description>&lt;P&gt;My programs uses the trim function within the verify function .. your's didn't!. As such, you trimmed the variable, but then SAS right padded it before it got to the function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2017 02:20:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372488#M89068</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-07-02T02:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: Why "TRIM" and "VERIFY" functions fail to solve my problem?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372489#M89069</link>
      <description>&lt;P&gt;Understood now!&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2017 02:24:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372489#M89069</guid>
      <dc:creator>Zhanxiong</dc:creator>
      <dc:date>2017-07-02T02:24:50Z</dc:date>
    </item>
    <item>
      <title>Re: Why "TRIM" and "VERIFY" functions fail to solve my problem?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372536#M89081</link>
      <description>&lt;P&gt;SAS stores character variables as fixed length. When your actual value is shorter than the storage length it is padded on the right with spaces. &amp;nbsp;So this type of a statement does nothing since any spaces removed by the trim function are just added back when the value is saved back into the variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;charvar = trim(charvar);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 02 Jul 2017 13:27:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372536#M89081</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-07-02T13:27:36Z</dc:date>
    </item>
    <item>
      <title>Re: Why "TRIM" and "VERIFY" functions fail to solve my problem?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372546#M89087</link>
      <description>&lt;P&gt;Thanks for your crystal-clear explanation, appreciate it!&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2017 14:22:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372546#M89087</guid>
      <dc:creator>Zhanxiong</dc:creator>
      <dc:date>2017-07-02T14:22:32Z</dc:date>
    </item>
    <item>
      <title>Re: Why "TRIM" and "VERIFY" functions fail to solve my problem?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372547#M89088</link>
      <description>&lt;P&gt;Thanks for the helpful hint.&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2017 14:23:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372547#M89088</guid>
      <dc:creator>Zhanxiong</dc:creator>
      <dc:date>2017-07-02T14:23:20Z</dc:date>
    </item>
    <item>
      <title>Re: Why "TRIM" and "VERIFY" functions fail to solve my problem?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372549#M89090</link>
      <description>By the way, may I ask how do you highlight the SAS keyword in the code chunk?</description>
      <pubDate>Sun, 02 Jul 2017 14:29:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372549#M89090</guid>
      <dc:creator>Zhanxiong</dc:creator>
      <dc:date>2017-07-02T14:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: Why "TRIM" and "VERIFY" functions fail to solve my problem?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372620#M89124</link>
      <description>&lt;P&gt;If you click on &lt;STRONG&gt;Insert SAS Code&lt;/STRONG&gt; icon (looks like the SAS run icon) in the Rich Text editor on this site it will make a pop-up window were you can place your SAS code. In addition to attempting to highlight the SAS syntax it will also preserve your lines of text as-is instead of treating them as paragraphs like the normal edit box does. &amp;nbsp;To edit the text you have created this way put the cursor anywhere in the code block and click the icon. &amp;nbsp;Do not try to edit in the simple edit box or it will mess up the formatting.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/121384"&gt;@Zhanxiong&lt;/a&gt; wrote:&lt;BR /&gt;By the way, may I ask how do you highlight the SAS keyword in the code chunk?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2017 19:51:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372620#M89124</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-07-02T19:51:27Z</dc:date>
    </item>
    <item>
      <title>Re: Why "TRIM" and "VERIFY" functions fail to solve my problem?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372622#M89126</link>
      <description>Thanks, it works. I edited my original post.</description>
      <pubDate>Sun, 02 Jul 2017 20:01:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-quot-TRIM-quot-and-quot-VERIFY-quot-functions-fail-to-solve/m-p/372622#M89126</guid>
      <dc:creator>Zhanxiong</dc:creator>
      <dc:date>2017-07-02T20:01:01Z</dc:date>
    </item>
  </channel>
</rss>

