<?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: proc sql equivalent data step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-equivalent-data-step/m-p/810528#M319620</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;Typo?&lt;BR /&gt;&lt;BR /&gt;&lt;CODE class=" language-sas"&gt;.... then OUTPUT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Depends on whether you want to keep the unique observations or delete them.&lt;/P&gt;
&lt;P&gt;The SQL query was deleting the groups with only one observation.&lt;/P&gt;</description>
    <pubDate>Fri, 29 Apr 2022 03:22:08 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-04-29T03:22:08Z</dc:date>
    <item>
      <title>proc sql equivalent data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-equivalent-data-step/m-p/810522#M319616</link>
      <description>&lt;P&gt;Hi ,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what is the equivalent data step&amp;nbsp; for the below proc sql step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table test1 as&lt;BR /&gt;select GEO, pcode, state , suburb, street_name, street_number, &lt;BR /&gt;unit_number , typ , count(*) as cnt&lt;BR /&gt;from test&lt;BR /&gt;group by 1,2,3,4,5,6,7 ,8&lt;BR /&gt;having cnt &amp;gt;1;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried as below , but does not give the correct results&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=test;&lt;BR /&gt;by GEO pcode state&amp;nbsp; suburb street_name street_number&lt;BR /&gt;unit_number&amp;nbsp; typ&amp;nbsp;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data test1;&lt;BR /&gt;set TEST;&lt;BR /&gt;by GEO pcode state&amp;nbsp; suburb street_name street_number&amp;nbsp;&lt;/P&gt;
&lt;P&gt;unit_number&amp;nbsp; typ&amp;nbsp;;&lt;BR /&gt;if first.GEO&amp;nbsp; ne&amp;nbsp; last.GEO then output ;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 02:18:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-equivalent-data-step/m-p/810522#M319616</guid>
      <dc:creator>sfffdg</dc:creator>
      <dc:date>2022-04-29T02:18:05Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql equivalent data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-equivalent-data-step/m-p/810525#M319617</link>
      <description>&lt;P&gt;You only asked the data step to output the first and last observation for the groups with more than 2 observations.&lt;/P&gt;
&lt;P&gt;FIRST. and LAST. flags can only be 1 (true) or 0 (false).&lt;/P&gt;
&lt;P&gt;They will be EQUAL when both are TRUE &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;or both are FALSE&lt;/STRONG&gt;&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only observations you &lt;STRONG&gt;want&lt;/STRONG&gt; to remove are when there is only one in the group, which is when both are TRUE.&lt;/P&gt;
&lt;P&gt;If you want to group by all 8 BY variables then you need to test the flags for the last of the variables.&amp;nbsp; Testing the flags for just the first variable is equivalent to only grouping by that one variable in the SQL query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if first.TYP and last.TYP then delete;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 03:00:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-equivalent-data-step/m-p/810525#M319617</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-29T03:00:56Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql equivalent data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-equivalent-data-step/m-p/810526#M319618</link>
      <description>&lt;PRE&gt;Typo?&lt;BR /&gt;&lt;BR /&gt;&lt;CODE class=" language-sas"&gt;.... then OUTPUT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Apr 2022 03:12:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-equivalent-data-step/m-p/810526#M319618</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2022-04-29T03:12:34Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql equivalent data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-equivalent-data-step/m-p/810528#M319620</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;Typo?&lt;BR /&gt;&lt;BR /&gt;&lt;CODE class=" language-sas"&gt;.... then OUTPUT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Depends on whether you want to keep the unique observations or delete them.&lt;/P&gt;
&lt;P&gt;The SQL query was deleting the groups with only one observation.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 03:22:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-equivalent-data-step/m-p/810528#M319620</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-29T03:22:08Z</dc:date>
    </item>
  </channel>
</rss>

