<?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 rows in data step in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/deleting-rows-in-data-step/m-p/181007#M46110</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; create table totarecs as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; select * from test where&amp;nbsp; group by id having count&amp;lt;1000; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Oct 2014 19:08:50 GMT</pubDate>
    <dc:creator>LearnByMistk</dc:creator>
    <dc:date>2014-10-10T19:08:50Z</dc:date>
    <item>
      <title>deleting rows in data step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/deleting-rows-in-data-step/m-p/181002#M46105</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a data file with account related info.&amp;nbsp; What I'm trying to do is if an account number occurs more than once I want to delete that row.&amp;nbsp; How do I achieve this in the below data step.&amp;nbsp; thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt; set dataIN;&lt;BR /&gt;file "c:\test_file.txt";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if&amp;nbsp; _freq_&amp;nbsp; &amp;gt;&amp;nbsp; 2 then delete;&amp;nbsp;&amp;nbsp; /* this is my addition to delete the row*/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;put&lt;/P&gt;&lt;P&gt;@001 acct_name&amp;nbsp; $50.&lt;/P&gt;&lt;P&gt;@051 address $50.&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&amp;nbsp; Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Oct 2014 17:47:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/deleting-rows-in-data-step/m-p/181002#M46105</guid>
      <dc:creator>sasboy007</dc:creator>
      <dc:date>2014-10-10T17:47:56Z</dc:date>
    </item>
    <item>
      <title>Re: deleting rows in data step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/deleting-rows-in-data-step/m-p/181003#M46106</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is the data sorted by the information that determines a duplicate? If not you are asking for a lot if there are more than a few records.&lt;/P&gt;&lt;P&gt;Easiest would be&lt;/P&gt;&lt;P&gt;Proc Sort data=yourdata out=want nodupkey; by &amp;lt;list of variables that determine uniqueness&amp;gt;; run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Oct 2014 17:57:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/deleting-rows-in-data-step/m-p/181003#M46106</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-10-10T17:57:53Z</dc:date>
    </item>
    <item>
      <title>Re: deleting rows in data step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/deleting-rows-in-data-step/m-p/181004#M46107</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry let me restate my question.&amp;nbsp; If an acct_name occurs more than 1000 times i need to delete all rows for that given account from the file. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;yeah the data is sorted by acct_name. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Oct 2014 18:05:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/deleting-rows-in-data-step/m-p/181004#M46107</guid>
      <dc:creator>sasboy007</dc:creator>
      <dc:date>2014-10-10T18:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: deleting rows in data step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/deleting-rows-in-data-step/m-p/181005#M46108</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If data is sorted by acct_name then this will retain acct_names occuring once in test_file.txt&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;set dataIN;&lt;/P&gt;&lt;P&gt;file "C:\test_file.txt";&lt;/P&gt;&lt;P&gt;by acct_name;&lt;/P&gt;&lt;P&gt;if first.acct_name and last.acct_name;&lt;/P&gt;&lt;P&gt;put &lt;/P&gt;&lt;P&gt;@001 acct_name&amp;nbsp; $50.&lt;/P&gt;&lt;P&gt;@051 address $50.&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Oct 2014 18:40:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/deleting-rows-in-data-step/m-p/181005#M46108</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-10-10T18:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: deleting rows in data step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/deleting-rows-in-data-step/m-p/181006#M46109</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You'll need a step to count occurrences of account numbers.&amp;nbsp; Here's one way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;n_accounts=0;&lt;/P&gt;&lt;P&gt;do until (last.acct_name);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set dataIN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by acct_name;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; n_accounts + 1;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;file "C:\test_file.txt";&lt;/P&gt;&lt;P&gt;do until (last.acct_name);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set dataIN;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by acct_name;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if n_accounts &amp;lt;= 1000 then put&lt;/P&gt;&lt;P&gt;&amp;nbsp; @001 acct_name $50.&lt;/P&gt;&lt;P&gt;&amp;nbsp; @051 address $40.&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You are reading the data twice, but there isn't any way around that.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Oct 2014 18:48:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/deleting-rows-in-data-step/m-p/181006#M46109</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-10-10T18:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: deleting rows in data step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/deleting-rows-in-data-step/m-p/181007#M46110</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; create table totarecs as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; select * from test where&amp;nbsp; group by id having count&amp;lt;1000; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Oct 2014 19:08:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/deleting-rows-in-data-step/m-p/181007#M46110</guid>
      <dc:creator>LearnByMistk</dc:creator>
      <dc:date>2014-10-10T19:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: deleting rows in data step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/deleting-rows-in-data-step/m-p/181008#M46111</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Astounding,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the loop statement that was helpful.&amp;nbsp; Can I take it a step further?&amp;nbsp; Let's say I didn't want to completely remove that account with 1000 rows.&amp;nbsp; If I wanted to implement a WHILE statement to end at a specific point.&amp;nbsp; The below is what I have, but doesn't stop at 500 or less for each account.&amp;nbsp; Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;file "C:\test_file.txt";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;n_accounts=0;&lt;/P&gt;&lt;P&gt;do until (last.acct_name);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set dataIN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by acct_name;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; n_accounts + 1;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do while(n_accounts &amp;lt;= 500);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set dataIN;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by acct_name;&lt;/P&gt;&lt;P&gt;put&lt;/P&gt;&lt;P&gt; @001 acct_name $50.&lt;/P&gt;&lt;P&gt; @051 address $40.&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Oct 2014 19:33:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/deleting-rows-in-data-step/m-p/181008#M46111</guid>
      <dc:creator>sasboy007</dc:creator>
      <dc:date>2014-10-13T19:33:29Z</dc:date>
    </item>
  </channel>
</rss>

