<?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 select observations by group (group by is not working) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-select-observations-by-group-group-by-is-not-working/m-p/640241#M190643</link>
    <description>&lt;LI-CODE lang="sas"&gt; where  (event='vis1')*cnsdt ;&lt;/LI-CODE&gt;
&lt;P&gt;is a boolean expression equivalent to&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where event='vis1' and not missing(dnsdt);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Boolean expressions are mathematical expressions that standardises values into binary 1's and 0' for true and false. I use these a lot considering the utility is phenomenal in the data prep for logistic regression for my credit risk team. You will pick up by practice. The people who inspired me to use this are&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21262"&gt;@hashman&lt;/a&gt;&amp;nbsp; and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;&amp;nbsp; &amp;nbsp;They showed me the usage in terms of brevity but it furthered to get me using in Probability models. So I would recommend reading their posts.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS Honestly they were gracious to lend me their time and I think they have gotten old now to do the same for today's newbies. lol&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Apr 2020 21:51:36 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2020-04-15T21:51:36Z</dc:date>
    <item>
      <title>proc sql select observations by group (group by is not working)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-select-observations-by-group-group-by-is-not-working/m-p/640230#M190637</link>
      <description>&lt;P&gt;Hi experts, i have a dataset similar to the dataset(with 5000 subjids) below.&lt;/P&gt;
&lt;P&gt;i need to extract the unique subjid who doesn't have cnsdt missing for vis1 only for which i have written a sql code below. kindly let me know the possible reason behind group by is getting converted in to order by as the warning appears in the log and the values i'm getting are all wrong.&lt;/P&gt;
&lt;P&gt;data a;&lt;/P&gt;
&lt;P&gt;input subjid event cnsdt;&lt;/P&gt;
&lt;P&gt;01001 vis1 12/03/2018&lt;/P&gt;
&lt;P&gt;01001 vis2&amp;nbsp;&lt;/P&gt;
&lt;P&gt;01001 vis3&lt;/P&gt;
&lt;P&gt;01001 vis4&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;01002 vis1 08/08/2018&lt;/P&gt;
&lt;P&gt;01002 vis2&amp;nbsp;&lt;/P&gt;
&lt;P&gt;01002 vis3&lt;/P&gt;
&lt;P&gt;01002 vis4&lt;/P&gt;
&lt;P&gt;01003 vis1 .&amp;nbsp;&lt;/P&gt;
&lt;P&gt;01003 vis2&amp;nbsp;&lt;/P&gt;
&lt;P&gt;01003 vis3&lt;/P&gt;
&lt;P&gt;01003 vis4&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;01004 vis1 23/02/2018&lt;/P&gt;
&lt;P&gt;01004 vis2&amp;nbsp;&lt;/P&gt;
&lt;P&gt;01004 vis3&lt;/P&gt;
&lt;P&gt;01004 vis4&lt;/P&gt;
&lt;P&gt;01005 vis1 .&lt;/P&gt;
&lt;P&gt;01005 vis2&amp;nbsp;&lt;/P&gt;
&lt;P&gt;01005 vis3&lt;/P&gt;
&lt;P&gt;01005 vis4&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table missconsdt as select distinct subjid from a where cnsdt ^=. group by subjid;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;any other better ways to do this in datastep, without using sql?Kindly suggest&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 21:17:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-select-observations-by-group-group-by-is-not-working/m-p/640230#M190637</guid>
      <dc:creator>sahoositaram555</dc:creator>
      <dc:date>2020-04-15T21:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql select observations by group (group by is not working)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-select-observations-by-group-group-by-is-not-working/m-p/640235#M190639</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
infile cards truncover;
input subjid $ event $ cnsdt :ddmmyy10.;
format  cnsdt ddmmyy10.;
cards;
01001 vis1 12/03/2018
01001 vis2 
01001 vis3
01001 vis4  
01002 vis1 08/08/2018
01002 vis2 
01002 vis3
01002 vis4
01003 vis1 . 
01003 vis2 
01003 vis3
01003 vis4  
01004 vis1 23/02/2018
01004 vis2 
01004 vis3
01004 vis4
01005 vis1 .
01005 vis2 
01005 vis3
01005 vis4
;
run;

 
proc sql;
create table missconsdt as 
select  subjid 
from a 
where (event='vis1')*cnsdt ;
quit;
proc print noobs;run;

data missconsdt;
 set a;
 where  (event='vis1')*cnsdt ;
run;
proc print noobs;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.MISSCONSDT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;subjid&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;01001&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;01002&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;01004&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 15 Apr 2020 21:28:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-select-observations-by-group-group-by-is-not-working/m-p/640235#M190639</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-04-15T21:28:20Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql select observations by group (group by is not working)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-select-observations-by-group-group-by-is-not-working/m-p/640238#M190640</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt; for the wonderful response. it's working perfectly . before i close your response as a solution, i would like to understand the syntax behind using the line &lt;BR /&gt;"where (event='vis1')*cnsdt "&lt;BR /&gt;Does cnsdt ^=. will be directly interpreted like that by SAS, by mentioning just the cnsdt (which i can see though from the results ,but what if i would like to do the vice versa , where (event='vis1')*-cnsdt, will this work )? or am i missing something. &lt;BR /&gt;Looking forward to having your response. Any paper for reference can be shared from your end would be helpful.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 21:42:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-select-observations-by-group-group-by-is-not-working/m-p/640238#M190640</guid>
      <dc:creator>sahoositaram555</dc:creator>
      <dc:date>2020-04-15T21:42:10Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql select observations by group (group by is not working)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-select-observations-by-group-group-by-is-not-working/m-p/640241#M190643</link>
      <description>&lt;LI-CODE lang="sas"&gt; where  (event='vis1')*cnsdt ;&lt;/LI-CODE&gt;
&lt;P&gt;is a boolean expression equivalent to&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where event='vis1' and not missing(dnsdt);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Boolean expressions are mathematical expressions that standardises values into binary 1's and 0' for true and false. I use these a lot considering the utility is phenomenal in the data prep for logistic regression for my credit risk team. You will pick up by practice. The people who inspired me to use this are&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21262"&gt;@hashman&lt;/a&gt;&amp;nbsp; and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;&amp;nbsp; &amp;nbsp;They showed me the usage in terms of brevity but it furthered to get me using in Probability models. So I would recommend reading their posts.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS Honestly they were gracious to lend me their time and I think they have gotten old now to do the same for today's newbies. lol&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 21:51:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-select-observations-by-group-group-by-is-not-working/m-p/640241#M190643</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-04-15T21:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql select observations by group (group by is not working)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-select-observations-by-group-group-by-is-not-working/m-p/640281#M190668</link>
      <description>&lt;P&gt;A slight, but important correction:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where event='vis1' and cnsdt not in (0,.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;A non-missing value of zero will cause the multiplication to also result in zero, which is considered "false".&lt;/P&gt;</description>
      <pubDate>Thu, 16 Apr 2020 06:31:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-select-observations-by-group-group-by-is-not-working/m-p/640281#M190668</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-16T06:31:18Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql select observations by group (group by is not working)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-select-observations-by-group-group-by-is-not-working/m-p/640366#M190727</link>
      <description>&lt;P&gt;Indeed that's sharp. Agreed &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Apr 2020 10:35:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-select-observations-by-group-group-by-is-not-working/m-p/640366#M190727</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-04-16T10:35:33Z</dc:date>
    </item>
  </channel>
</rss>

