<?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 one specific value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Removing-one-specific-value/m-p/443347#M110905</link>
    <description>&lt;P&gt;couple of ways to do is to create a new dataset or use update statement&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA Have;
INPUT ID VAR1$ VAR4$ VAR6$;
DATALINES;
101 ENG1 15225555 NY
105 Che1 10222541 NY
109 Eng2 999999 CA
115 Phy2 1156858 PA
201 Che1 99999999 TX
;
RUN;

data want;
set have;
if trim(var4)  = '999999' then var4 = ' ' ;
else var4 = var4;
run;

proc sql;
update have
set var4 = ' '
where trim(var4)  = '999999';&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 07 Mar 2018 15:23:11 GMT</pubDate>
    <dc:creator>kiranv_</dc:creator>
    <dc:date>2018-03-07T15:23:11Z</dc:date>
    <item>
      <title>Removing one specific value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-one-specific-value/m-p/443333#M110903</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;I wanted to know what would be the best command to remove one specific value from a variable. For example, I want to remove the value '999999' (a value containing 6 nines) from VAR4 of the following table.&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;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA Have;
INPUT ID VAR1$ VAR4$ VAR6$;
DATALINES;
101 ENG1 15225555 NY
105 Che1 10222541 NY
109 Eng2 999999 CA
115 Phy2 1156858 PA
201 Che1 99999999 TX
;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Expected output table:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID&amp;nbsp; &amp;nbsp;VAR1&amp;nbsp; &amp;nbsp;VAR4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; VAR6&lt;/P&gt;
&lt;P&gt;101 ENG1 15225555&amp;nbsp; NY&lt;BR /&gt;105 Che1 10222541&amp;nbsp; &amp;nbsp;NY&lt;BR /&gt;109 Eng2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CA&lt;BR /&gt;115 Phy2 1156858&amp;nbsp; &amp;nbsp; &amp;nbsp; PA&lt;BR /&gt;201 Che1 99999999&amp;nbsp; &amp;nbsp;TX&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 15:01:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-one-specific-value/m-p/443333#M110903</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2018-03-07T15:01:57Z</dc:date>
    </item>
    <item>
      <title>Re: Removing one specific value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-one-specific-value/m-p/443347#M110905</link>
      <description>&lt;P&gt;couple of ways to do is to create a new dataset or use update statement&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA Have;
INPUT ID VAR1$ VAR4$ VAR6$;
DATALINES;
101 ENG1 15225555 NY
105 Che1 10222541 NY
109 Eng2 999999 CA
115 Phy2 1156858 PA
201 Che1 99999999 TX
;
RUN;

data want;
set have;
if trim(var4)  = '999999' then var4 = ' ' ;
else var4 = var4;
run;

proc sql;
update have
set var4 = ' '
where trim(var4)  = '999999';&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Mar 2018 15:23:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-one-specific-value/m-p/443347#M110905</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2018-03-07T15:23:11Z</dc:date>
    </item>
    <item>
      <title>Re: Removing one specific value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-one-specific-value/m-p/443348#M110906</link>
      <description>&lt;PRE&gt;data want;
  set have;
  if index(var4,"999999") then delete;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Mar 2018 15:24:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-one-specific-value/m-p/443348#M110906</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-03-07T15:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: Removing one specific value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-one-specific-value/m-p/443402#M110930</link>
      <description>&lt;P&gt;It's an easy change ... use an easy program:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;if var4='999999' then var4=' ';&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This works as long as there are no leading&amp;nbsp; blanks before the "999999".&amp;nbsp; If there are any leading blanks, however, you might need to specify whether those should be changed as well.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 16:21:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-one-specific-value/m-p/443402#M110930</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-03-07T16:21:37Z</dc:date>
    </item>
    <item>
      <title>Re: Removing one specific value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-one-specific-value/m-p/443410#M110931</link>
      <description>&lt;P&gt;Hi RW9,&lt;BR /&gt;Your index function works, but it is removing '99999999' instead of '999999' also it is working for Numeric variable. do you know how I should modify your code if it is a Character value?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 16:51:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-one-specific-value/m-p/443410#M110931</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2018-03-07T16:51:17Z</dc:date>
    </item>
    <item>
      <title>Re: Removing one specific value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-one-specific-value/m-p/443442#M110943</link>
      <description>&lt;P&gt;First, your test data shows var4 as a character variable, hence why I showed this example.&amp;nbsp; Index searches for a string within another one, e.g. "9999999" contains "999999".&amp;nbsp; If you apply this to numbers then the function will implicitly convert the number to character.&amp;nbsp; If its just to remove that one data item, why not:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  if strip(var4)="999999" then var4="";
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Mar 2018 18:12:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-one-specific-value/m-p/443442#M110943</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-03-07T18:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: Removing one specific value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-one-specific-value/m-p/443448#M110945</link>
      <description>Hi RW9,&lt;BR /&gt;Would you please test if this is code is working at your end. It's not working at my end. May be I am missing something. I want to get rid of a value where there is 6 9s only, NOT 99999999. &lt;BR /&gt;&lt;BR /&gt;DATA Have;&lt;BR /&gt;INPUT ID VAR1$ VAR$ VAR6$;&lt;BR /&gt;DATALINES;&lt;BR /&gt;101 ENG1 15225555 NY&lt;BR /&gt;105 Che1 10222541 NY&lt;BR /&gt;109 Eng2 999999 CA&lt;BR /&gt;115 Phy2 1156858 PA&lt;BR /&gt;201 Che1 99999999 TX&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;  set have;&lt;BR /&gt;  if strip(var4)="999999" then var4="";&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks,</description>
      <pubDate>Wed, 07 Mar 2018 18:35:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-one-specific-value/m-p/443448#M110945</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2018-03-07T18:35:20Z</dc:date>
    </item>
    <item>
      <title>Re: Removing one specific value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-one-specific-value/m-p/443452#M110946</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA WANT;
SET HAVE;
VAR4=IFC(strip(var4)="999999"," ",var4);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Mar 2018 18:42:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-one-specific-value/m-p/443452#M110946</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-03-07T18:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: Removing one specific value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-one-specific-value/m-p/443501#M110956</link>
      <description>Hi SuryaKiran,&lt;BR /&gt;Is the code working for you?</description>
      <pubDate>Wed, 07 Mar 2018 20:50:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-one-specific-value/m-p/443501#M110956</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2018-03-07T20:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: Removing one specific value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-one-specific-value/m-p/443508#M110960</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35631"&gt;@mlogan&lt;/a&gt; wrote:&lt;BR /&gt;Hi RW9,&lt;BR /&gt;Would you please test if this is code is working at your end. It's not working at my end. May be I am missing something. I want to get rid of a value where there is 6 9s only, NOT 99999999. &lt;BR /&gt;&lt;BR /&gt;DATA Have;&lt;BR /&gt;INPUT ID VAR1$ VAR$ VAR6$;&lt;BR /&gt;DATALINES;&lt;BR /&gt;101 ENG1 15225555 NY&lt;BR /&gt;105 Che1 10222541 NY&lt;BR /&gt;109 Eng2 999999 CA&lt;BR /&gt;115 Phy2 1156858 PA&lt;BR /&gt;201 Che1 99999999 TX&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt; set have;&lt;BR /&gt; if strip(var4)="999999" then var4="";&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That doesn't work because you have changed the name of the variable. In your data step you have&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="SAS Monospace" size="2"&gt;INPUT&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt; ID VAR1$ VAR$ VAR6$;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;so there is no VAR4.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 21:00:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-one-specific-value/m-p/443508#M110960</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-03-07T21:00:08Z</dc:date>
    </item>
    <item>
      <title>Re: Removing one specific value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-one-specific-value/m-p/443557#M110978</link>
      <description>&lt;P&gt;Yes, It works fine for me. Try COMPRESS() to remove any blanks between 9's&lt;/P&gt;&lt;P&gt;DATA WANT;&lt;BR /&gt;SET HAVE;&lt;BR /&gt;VAR4=IFC(COMPRESS(var4)="999999"," ",var4);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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: 553px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/19043i6C5AFCD7375C2690/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 23:34:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-one-specific-value/m-p/443557#M110978</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-03-07T23:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: Removing one specific value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-one-specific-value/m-p/443692#M111023</link>
      <description>&lt;P&gt;No this code does not work, the reason is quite clear:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;DATA Have;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;INPUT ID VAR1$ VAR$ VAR6$;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;^&amp;nbsp; &amp;nbsp; &amp;nbsp; ^&amp;nbsp; Variable is called var here, not var4 hence the use of var4 in next step fails.&lt;BR /&gt;&lt;SPAN&gt;DATALINES;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;101 ENG1 15225555 NY&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;105 Che1 10222541 NY&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;109 Eng2 999999 CA&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;115 Phy2 1156858 PA&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;201 Che1 99999999 TX&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RUN;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;data want;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;set have;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if strip(var4)="999999" then var4="";&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ^&amp;nbsp; &amp;nbsp; &amp;nbsp; ^ no var4 in dataset!!&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This works fine (note how I use the code window and apply good formatting!):&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;data have;
  input id var1 $ var4 $ var6 $;
datalines;
101 ENG1 15225555 NY
105 Che1 10222541 NY
109 Eng2 999999 CA
115 Phy2 1156858 PA
201 Che1 99999999 TX
;
run;;

data want;
  set have;
  if strip(var)="999999" then var="";
run;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Mar 2018 09:29:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-one-specific-value/m-p/443692#M111023</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-03-08T09:29:31Z</dc:date>
    </item>
  </channel>
</rss>

