<?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: using the Where statement in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/using-the-Where-statement/m-p/696599#M25283</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/222563"&gt;@hjjijkkl&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you genuinely are trying to use the &lt;FONT face="courier new,courier"&gt;missing()&lt;/FONT&gt; function then check the &lt;A href="https://documentation.sas.com/?cdcId=vdmmlcdc&amp;amp;cdcVersion=1.0&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p06ybg84o0asa4n17l9ieauk58hb.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;documentation&lt;/A&gt;&amp;nbsp;which also shows some examples of how to use it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try posting rows of representative example data, showing which rows you want to be processed by &lt;FONT face="courier new,courier"&gt;proc freq&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
    <pubDate>Wed, 04 Nov 2020 17:22:53 GMT</pubDate>
    <dc:creator>Amir</dc:creator>
    <dc:date>2020-11-04T17:22:53Z</dc:date>
    <item>
      <title>using the Where statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/using-the-Where-statement/m-p/696588#M25279</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to use the Where Statement in a proc freq to select specific subject but, my program is not working. please see the program below.&lt;/P&gt;
&lt;P&gt;I am trying to find individ with no missing mod_date but missing status=1 but not missing status=2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc frq data=temp;&lt;/P&gt;
&lt;P&gt;where not(missing(mod_date))and missing(status=1) and status=2;&lt;/P&gt;
&lt;P&gt;run;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 16:55:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/using-the-Where-statement/m-p/696588#M25279</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2020-11-04T16:55:46Z</dc:date>
    </item>
    <item>
      <title>Re: using the Where statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/using-the-Where-statement/m-p/696593#M25281</link>
      <description>&lt;P&gt;Does the LOG contain errors? Can you determine from that what is wrong?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Did you type the code properly? (No you didn't, there is no such thing as PROC FRQ, and possibly other errors as well)&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;What does "&lt;SPAN&gt;missing status=1 but not missing status=2"&lt;/SPAN&gt; really mean? Do you have a variable named status or a variable named missing_status? What are your variable names in the SAS data set?&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 17:11:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/using-the-Where-statement/m-p/696593#M25281</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-11-04T17:11:23Z</dc:date>
    </item>
    <item>
      <title>Re: using the Where statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/using-the-Where-statement/m-p/696598#M25282</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/222563"&gt;@hjjijkkl&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to use the Where Statement in a proc freq to select specific subject but, my program is not working. please see the program below.&lt;/P&gt;
&lt;P&gt;I am trying to find individ with no missing mod_date but missing status=1 but not missing status=2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc frq data=temp;&lt;/P&gt;
&lt;P&gt;where not(missing(mod_date))and missing(status=1) and status=2;&lt;/P&gt;
&lt;P&gt;run;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This bit of your where is never true:&lt;/P&gt;
&lt;PRE&gt;missing(status=1) &lt;/PRE&gt;
&lt;P&gt;What SAS does with something like that is compare the variable STATUS to the value 1. If Status is missing or any value except 1 the comparison returns 0, otherwise a value of 1. So you are basically asking to see if 0 is missing (false) or 1 is missing (false).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since a variable will only have one value per record, which is what Where looks at, then you need to describe, i.e. provide data with values, which records you want processed because "missing status=1 but not missing status=2" makes absolutely no sense in a per record context.&lt;/P&gt;
&lt;P&gt;If you mean to look across all the values and apply a rule then you will need to subset your data prior to proc freq but how to do that really means we need to see some example data.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 17:22:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/using-the-Where-statement/m-p/696598#M25282</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-11-04T17:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: using the Where statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/using-the-Where-statement/m-p/696599#M25283</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/222563"&gt;@hjjijkkl&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you genuinely are trying to use the &lt;FONT face="courier new,courier"&gt;missing()&lt;/FONT&gt; function then check the &lt;A href="https://documentation.sas.com/?cdcId=vdmmlcdc&amp;amp;cdcVersion=1.0&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p06ybg84o0asa4n17l9ieauk58hb.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;documentation&lt;/A&gt;&amp;nbsp;which also shows some examples of how to use it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try posting rows of representative example data, showing which rows you want to be processed by &lt;FONT face="courier new,courier"&gt;proc freq&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 17:22:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/using-the-Where-statement/m-p/696599#M25283</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2020-11-04T17:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: using the Where statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/using-the-Where-statement/m-p/696602#M25284</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;status=1&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is a boolean expression that results in either 0 or 1, so it can never be missing. Since you combine all conditions with AND, the whole condition will never be true.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 17:36:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/using-the-Where-statement/m-p/696602#M25284</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-04T17:36:13Z</dc:date>
    </item>
    <item>
      <title>Re: using the Where statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/using-the-Where-statement/m-p/696604#M25285</link>
      <description>&lt;P&gt;Are you trying to check if the vlaue of STATUS is either 1 or 2?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so you might want to use the IN operator.&amp;nbsp; This will find records with STATUS of either 1 or 2 that do not have a missing MOD_DATE.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where not missing(mod_date) and status in (1 2);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To test for missing you can use period.&amp;nbsp; This will find records with status of missing or 2.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where not missing(mod_date) and status in (. 2);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But watch out for special missing values like .A,.B,...,.Z and ._ .&amp;nbsp; If your values might have special missing values might want to code that second example using the missing() function instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where not missing(mod_date) and (status=2 or missing(status));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Nov 2020 17:39:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/using-the-Where-statement/m-p/696604#M25285</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-11-04T17:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: using the Where statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/using-the-Where-statement/m-p/696607#M25286</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/222563"&gt;@hjjijkkl&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Further to the explanation&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;has given about comparing values, you have to be sure the types of the variables / values you are comparing are the same, otherwise you might get an error such as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;34         proc freq data = sashelp.class;
35            where missing(name=1);
ERROR: WHERE clause operator requires compatible variables.
36         run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 17:41:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/using-the-Where-statement/m-p/696607#M25286</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2020-11-04T17:41:35Z</dc:date>
    </item>
    <item>
      <title>Re: using the Where statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/using-the-Where-statement/m-p/696629#M25287</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;Yes, I have three variables ( ID, Status, Mod_date). the status contains obs (1, 2, 3). I am trying to find the number IDs missing status 1 but have status 2 and 3.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 18:36:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/using-the-Where-statement/m-p/696629#M25287</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2020-11-04T18:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: using the Where statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/using-the-Where-statement/m-p/696633#M25288</link>
      <description>&lt;P&gt;Please show us a portion of your data.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 18:40:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/using-the-Where-statement/m-p/696633#M25288</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-11-04T18:40:24Z</dc:date>
    </item>
    <item>
      <title>Re: using the Where statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/using-the-Where-statement/m-p/696643#M25292</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/222563"&gt;@hjjijkkl&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;Yes, I have three variables ( ID, Status, Mod_date). the status contains obs (1, 2, 3). I am trying to find the number IDs missing status 1 but have status 2 and 3.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You cannot do that with a simple WHERE as you need to check across observations.&lt;/P&gt;
&lt;P&gt;You might want to aggregate the data to a single observation per ID.&lt;/P&gt;
&lt;P&gt;Here is method using data step, note it requires that data is sorted by ID.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  by id;
  retain has1 has2 has3 ;
  if first.id then call missing(has1,has2,has3);
  if status=1 then has1=1;
  if status=2 then has2 =1;
  if status=3 then has3=1;
  if last.id;
  keep id has1-has3;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now you test is just (HAS2 and HAS3 and NOT HAS1) .&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 18:59:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/using-the-Where-statement/m-p/696643#M25292</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-11-04T18:59:44Z</dc:date>
    </item>
  </channel>
</rss>

