<?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: Removing records with variable value contain '-' in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Removing-records-with-variable-value-contain/m-p/576401#M163145</link>
    <description>&lt;P&gt;The data step is not going to recognize LIKE as an operator.&amp;nbsp; That only works in PROC SQL code or in WHERE statements.&lt;/P&gt;</description>
    <pubDate>Wed, 24 Jul 2019 23:31:32 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-07-24T23:31:32Z</dc:date>
    <item>
      <title>Removing records with variable value contain '-'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-records-with-variable-value-contain/m-p/576398#M163142</link>
      <description>&lt;P&gt;Hi.. I have a dataset where a variable called ACCT_NO (character).. In there, some of the records have ACCT_NO contain '-' and some don't.. My goal is to remove those have '-' in their ACCT_NO and turn the rest's ACCT_NO into numeric..&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code but I got the error message.. Anyone know what the error is? Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data datasetB;
	set datasetA;
	if ACCT_NO like '%-%' then delete;
	ACCTKEY = input(ACCT_NO,19.);
run;

8548   data datasetB;
8549       set datasetA;
8550       if ACCT_NO like '%-%' then delete;
                      ----
                      388
                      76
ERROR 388-185: Expecting an arithmetic operator.

ERROR 76-322: Syntax error, statement will be ignored.&lt;/CODE&gt;&lt;/PRE&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>Wed, 24 Jul 2019 23:20:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-records-with-variable-value-contain/m-p/576398#M163142</guid>
      <dc:creator>newboy1218</dc:creator>
      <dc:date>2019-07-24T23:20:09Z</dc:date>
    </item>
    <item>
      <title>Re: Removing records with variable value contain '-'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-records-with-variable-value-contain/m-p/576399#M163143</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data datasetB;
	set datasetA;
	if not index(ACCT_NO,'-') ;
	ACCTKEY = input(ACCT_NO,best.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Jul 2019 23:24:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-records-with-variable-value-contain/m-p/576399#M163143</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-07-24T23:24:54Z</dc:date>
    </item>
    <item>
      <title>Re: Removing records with variable value contain '-'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-records-with-variable-value-contain/m-p/576400#M163144</link>
      <description>&lt;P&gt;But doesn't INDEX function return the position of a string? In that case, shouldn't I use this instead?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if index(ACCT_NO,'-') = 0;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Jul 2019 23:31:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-records-with-variable-value-contain/m-p/576400#M163144</guid>
      <dc:creator>newboy1218</dc:creator>
      <dc:date>2019-07-24T23:31:11Z</dc:date>
    </item>
    <item>
      <title>Re: Removing records with variable value contain '-'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-records-with-variable-value-contain/m-p/576401#M163145</link>
      <description>&lt;P&gt;The data step is not going to recognize LIKE as an operator.&amp;nbsp; That only works in PROC SQL code or in WHERE statements.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2019 23:31:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-records-with-variable-value-contain/m-p/576401#M163145</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-24T23:31:32Z</dc:date>
    </item>
    <item>
      <title>Re: Removing records with variable value contain '-'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-records-with-variable-value-contain/m-p/576402#M163146</link>
      <description>&lt;P&gt;I see. Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2019 23:32:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-records-with-variable-value-contain/m-p/576402#M163146</guid>
      <dc:creator>newboy1218</dc:creator>
      <dc:date>2019-07-24T23:32:29Z</dc:date>
    </item>
    <item>
      <title>Re: Removing records with variable value contain '-'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-records-with-variable-value-contain/m-p/576403#M163147</link>
      <description>&lt;P&gt;yes you can which is the equivalent of &lt;STRONG&gt;NOT logical operatior(=0)&lt;/STRONG&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/211631"&gt;@newboy1218&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;But doesn't INDEX function return the position of a string? In that case, shouldn't I use this instead?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if index(ACCT_NO,'-') = 0;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;perator&lt;/STRONG&gt;. Your style is just as good.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2019 23:33:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-records-with-variable-value-contain/m-p/576403#M163147</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-07-24T23:33:26Z</dc:date>
    </item>
    <item>
      <title>Re: Removing records with variable value contain '-'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-records-with-variable-value-contain/m-p/576404#M163148</link>
      <description>&lt;P&gt;Test this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ACCT_NO :$10.;
cards;
123-678
4567
4657-78
57567
;

data want;
	set have;
	if not index(ACCT_NO,'-') ;
	ACCTKEY = input(ACCT_NO,best.);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2019 23:35:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-records-with-variable-value-contain/m-p/576404#M163148</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-07-24T23:35:19Z</dc:date>
    </item>
    <item>
      <title>Re: Removing records with variable value contain '-'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-records-with-variable-value-contain/m-p/576405#M163149</link>
      <description>&lt;P&gt;Also:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data datasetB;
  set datasetA;
  where ACCT_NO not like '%-%' ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The like operator is not as efficient as the index function though.&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>Wed, 24 Jul 2019 23:48:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-records-with-variable-value-contain/m-p/576405#M163149</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-07-24T23:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: Removing records with variable value contain '-'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-records-with-variable-value-contain/m-p/576406#M163150</link>
      <description>&lt;P&gt;I am gonna use 'index' now. But thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2019 23:48:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-records-with-variable-value-contain/m-p/576406#M163150</guid>
      <dc:creator>newboy1218</dc:creator>
      <dc:date>2019-07-24T23:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: Removing records with variable value contain '-'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-records-with-variable-value-contain/m-p/576407#M163151</link>
      <description>&lt;P&gt;For 'index' can I check more than 1 strings?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for example, can I do&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if not index(ACCT_NO, '-') and not index(ACCT_NO, '/')?&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Jul 2019 23:50:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-records-with-variable-value-contain/m-p/576407#M163151</guid>
      <dc:creator>newboy1218</dc:creator>
      <dc:date>2019-07-24T23:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: Removing records with variable value contain '-'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-records-with-variable-value-contain/m-p/576408#M163152</link>
      <description>&lt;P&gt;Yes indeed. Now you are writing a compund expression wth logical operators NOT, AND &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2019 23:52:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-records-with-variable-value-contain/m-p/576408#M163152</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-07-24T23:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: Removing records with variable value contain '-'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-records-with-variable-value-contain/m-p/576409#M163153</link>
      <description>&lt;P&gt;It would have been faster to test than to ask.&lt;/P&gt;
&lt;P&gt;Yes you can.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2019 23:53:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-records-with-variable-value-contain/m-p/576409#M163153</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-07-24T23:53:28Z</dc:date>
    </item>
    <item>
      <title>Re: Removing records with variable value contain '-'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-records-with-variable-value-contain/m-p/576410#M163154</link>
      <description>&lt;P&gt;If your requirement is below unlike your original,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try &lt;STRONG&gt;indexC&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;For Example&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ACCT_NO :$10.;
cards;
123-678
4567
4657-/78
57567
;

data want;
	set have;
	if  indexc(ACCT_NO,'-/')=0 ;
	ACCTKEY = input(ACCT_NO,best.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2019 23:56:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-records-with-variable-value-contain/m-p/576410#M163154</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-07-24T23:56:18Z</dc:date>
    </item>
  </channel>
</rss>

