<?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: Deleting records with last.variable with a multi conditional if statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Deleting-records-with-last-variable-with-a-multi-conditional-if/m-p/273590#M54534</link>
    <description>&lt;P&gt;You will have read the documentation yes?&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/kb/43/303.html" target="_blank"&gt;http://support.sas.com/kb/43/303.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Contains only works on where clauses, you want:&lt;/P&gt;
&lt;P&gt;and index(source,"CIM") &amp;gt; 0 then...&lt;/P&gt;</description>
    <pubDate>Fri, 27 May 2016 14:28:15 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2016-05-27T14:28:15Z</dc:date>
    <item>
      <title>Deleting records with last.variable with a multi conditional if statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-records-with-last-variable-with-a-multi-conditional-if/m-p/273584#M54532</link>
      <description>&lt;P&gt;I want to delete the last record if certain conditions apply. However, I am getting the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ERROR 68-185: The function CONTAINS is unknown, or cannot be accessed.&lt;/PRE&gt;&lt;P&gt;Here is what I am working on:&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 test;
	format date date9.;
	input sn $
		  date
		  ctry $
		  source $;
	datalines;
	1 20000 US PL
	1 20001 US PL
	1 20005 US CIM  /*this would be removed*/
	2 20000 CA SOS
	2 25000 FR CIM  /*this would be kept*/
	;
run;

proc sort data = test;
	by sn date ctry;
run;

data test2;
	set test;
	by sn;
	if last.ctry = lag1(last.ctry) and (abs(last.date - lag1(last.date) &amp;lt; 180) 
		and source contains ('CIM') then delete;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 May 2016 14:08:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-records-with-last-variable-with-a-multi-conditional-if/m-p/273584#M54532</guid>
      <dc:creator>dwsmith</dc:creator>
      <dc:date>2016-05-27T14:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting records with last.variable with a multi conditional if statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-records-with-last-variable-with-a-multi-conditional-if/m-p/273588#M54533</link>
      <description>&lt;P&gt;Simple SAS does not have a datastep condition CONTAINS though it is availabe in Proc SQL. There are a number of other methods. I would likely use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;... and index(source,'CIM') &amp;gt; 0 then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If source might actual have lower case versions such as "cim" "Cim" "CiM" that you want to match as well then use&lt;/P&gt;
&lt;P&gt;index( Upcase(source),'CIM') &amp;gt;0&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2016 14:26:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-records-with-last-variable-with-a-multi-conditional-if/m-p/273588#M54533</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-05-27T14:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting records with last.variable with a multi conditional if statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-records-with-last-variable-with-a-multi-conditional-if/m-p/273590#M54534</link>
      <description>&lt;P&gt;You will have read the documentation yes?&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/kb/43/303.html" target="_blank"&gt;http://support.sas.com/kb/43/303.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Contains only works on where clauses, you want:&lt;/P&gt;
&lt;P&gt;and index(source,"CIM") &amp;gt; 0 then...&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2016 14:28:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-records-with-last-variable-with-a-multi-conditional-if/m-p/273590#M54534</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-05-27T14:28:15Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting records with last.variable with a multi conditional if statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-records-with-last-variable-with-a-multi-conditional-if/m-p/273643#M54548</link>
      <description>&lt;P&gt;Also, what do you expect LAST.CTRY and LAST.DATE to contain, given that neither CTRY nor DATE appears in the BY statement (cf. section "Processing BY Groups" in the &lt;A href="http://support.sas.com/documentation/cdl/en/lestmtsref/68024/HTML/default/viewer.htm#p0yeyftk8ftuckn1o5qzy53284gz.htm" target="_blank"&gt;documentation&lt;/A&gt;)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-------------------&lt;/P&gt;
&lt;P&gt;Side note: It's interesting to see that FIRST.&lt;EM&gt;xxx&lt;/EM&gt; and LAST.&lt;EM&gt;xxx&lt;/EM&gt; variables with arbitrary names &lt;EM&gt;xxx&lt;/EM&gt; can be freely used as temporary (i.e. automatically dropped) variables which are automatically retained and initialized to zero (not as index variables of DO loops, though).&amp;nbsp;Fun example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
set sashelp.class end=eof;
first.xy=sqrt(first.xy+1);
last.abc=1/(last.abc+1);
if eof then put first.xy= / last.abc= ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 May 2016 16:52:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-records-with-last-variable-with-a-multi-conditional-if/m-p/273643#M54548</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-27T16:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting records with last.variable with a multi conditional if statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-records-with-last-variable-with-a-multi-conditional-if/m-p/273662#M54551</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh﻿&lt;/a&gt;, interesting, but harmful knowledge. I hope I will never have to look at such coding!&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2016 17:43:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-records-with-last-variable-with-a-multi-conditional-if/m-p/273662#M54551</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-05-27T17:43:39Z</dc:date>
    </item>
  </channel>
</rss>

