<?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: How to Delete Entire Row if Conditions Are Met in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Entire-Row-if-Conditions-Are-Met/m-p/948337#M371091</link>
    <description>&lt;P&gt;Your logic should at least delete some rows from the sample data you've provided.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it's just about change then I'd be using the abs() function. To not mask cases with missings I wouldn't use the sum() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data weight_data;
  input ID Gender $ Starting_Weight End_Weight;
  del_flg=  0&amp;lt;=abs(Starting_Weight-End_Weight)&amp;lt;10;
/*  if 0&amp;lt;=abs(Starting_Weight-End_Weight)&amp;lt;10 then delete;*/
  datalines;
1 M 170 180
2 M 182 175
3 M 155 162
4 M 203 196
5 F 124 135
6 F 152 155
7 F 118 133
8 F 160 152
9 F . 152
;
run;

proc print data=weight_data;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 21 Oct 2024 08:09:29 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2024-10-21T08:09:29Z</dc:date>
    <item>
      <title>How to Delete Entire Row if Conditions Are Met</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Entire-Row-if-Conditions-Are-Met/m-p/948334#M371089</link>
      <description>&lt;P&gt;I have a concatenated data set from 2 data sets that looks something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ID     Gender   Starting_Weight    End_Weight

1        M            170                       180
2        M            182                       175
3        M            155                       162
4        M            203                       196
5        F            124                       135
6        F            152                       155
7        F            118                       133
8        F            160                       152&lt;/PRE&gt;&lt;P&gt;There are more observations, but what I want to do is remove all rows where the change between the weights is less than 10. Here is my atttempt:&lt;/P&gt;&lt;PRE&gt;data WeightsCombined;
	set WeightsMale WeightsFemale;
	Weight_change = sum(-Starting_Weight, End_Weight);
	if Weight_change&amp;lt;10 then delete;
run;

proc print data = WeightsCombined;
run;&lt;/PRE&gt;&lt;P&gt;For some reason, this outputs nothing. Why is an output not showing and how can I remove the rows that meet my condition?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2024 07:51:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Entire-Row-if-Conditions-Are-Met/m-p/948334#M371089</guid>
      <dc:creator>unwashedhelimix</dc:creator>
      <dc:date>2024-10-21T07:51:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to Delete Entire Row if Conditions Are Met</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Entire-Row-if-Conditions-Are-Met/m-p/948337#M371091</link>
      <description>&lt;P&gt;Your logic should at least delete some rows from the sample data you've provided.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it's just about change then I'd be using the abs() function. To not mask cases with missings I wouldn't use the sum() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data weight_data;
  input ID Gender $ Starting_Weight End_Weight;
  del_flg=  0&amp;lt;=abs(Starting_Weight-End_Weight)&amp;lt;10;
/*  if 0&amp;lt;=abs(Starting_Weight-End_Weight)&amp;lt;10 then delete;*/
  datalines;
1 M 170 180
2 M 182 175
3 M 155 162
4 M 203 196
5 F 124 135
6 F 152 155
7 F 118 133
8 F 160 152
9 F . 152
;
run;

proc print data=weight_data;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Oct 2024 08:09:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Entire-Row-if-Conditions-Are-Met/m-p/948337#M371091</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-10-21T08:09:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to Delete Entire Row if Conditions Are Met</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Entire-Row-if-Conditions-Are-Met/m-p/948358#M371093</link>
      <description>&lt;P&gt;Your SET statement looks wrong to me.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set WeightsMale WeightsFemale;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Do you really have the data in two separate datasets?&amp;nbsp; Do they have the same variables?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why use the SUM() function?&amp;nbsp; That will yield invalid results when only one of the readings is missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's save the intermediate calculations into variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input ID Gender :$1. Starting_Weight End_Weight;
cards;
1 M 170 180
2 M 182 175
3 M 155 162
4 M 203 196
5 F 124 135
6 F 152 155
7 F 118 133
8 F 160 152
;

data want;
  set have;
  weight_gain = end_weight - starting_weight;
  lessthan10 = weight_gain &amp;lt; 10;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is the result for your example:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1729511830097.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101603iDA7DB2158402DD5C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1729511830097.png" alt="Tom_0-1729511830097.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Which observations do you want to delete?&amp;nbsp; Your current logic would eliminate all but 3 of the observations, the ones where LESSTHAN10 variable has value 0.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2024 11:59:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Entire-Row-if-Conditions-Are-Met/m-p/948358#M371093</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-10-21T11:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to Delete Entire Row if Conditions Are Met</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Entire-Row-if-Conditions-Are-Met/m-p/948361#M371094</link>
      <description>&lt;P&gt;Another approach using ABS function. If we need to read only observations where change is greater than or equals 10 then&amp;nbsp; where statement is more efficient in terms of system processing.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	set have;
	where abs(starting_weight - end_weight) ge 10;
run; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Oct 2024 12:10:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Delete-Entire-Row-if-Conditions-Are-Met/m-p/948361#M371094</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2024-10-21T12:10:54Z</dc:date>
    </item>
  </channel>
</rss>

