<?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: WHERE syntax: How to appropriately use it in excluding mutiple variables needed for a data step in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/WHERE-syntax-How-to-appropriately-use-it-in-excluding-mutiple/m-p/577555#M13232</link>
    <description>&lt;P&gt;Wow!&lt;/P&gt;&lt;P&gt;Thanks for your quick response.&lt;/P&gt;&lt;P&gt;It worked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had tried writing all the WHERE's in one line but I was using an OR ..and it makes sense, OR will not pick all the columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I noticed that after using 'and' more than once, the color changes from blue to the variable color. I guess that doen not matter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A proc univariate showed that the ranges are within the expected values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much.&lt;/P&gt;</description>
    <pubDate>Mon, 29 Jul 2019 21:59:48 GMT</pubDate>
    <dc:creator>oadeyemi</dc:creator>
    <dc:date>2019-07-29T21:59:48Z</dc:date>
    <item>
      <title>WHERE syntax: How to appropriately use it in excluding mutiple variables needed for a data step</title>
      <link>https://communities.sas.com/t5/New-SAS-User/WHERE-syntax-How-to-appropriately-use-it-in-excluding-mutiple/m-p/577541#M13226</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;Good evening everyone.&lt;/DIV&gt;&lt;DIV&gt;I am having problems with the WHERE syntax. I think I am using it inappropriately.&lt;/DIV&gt;&lt;DIV&gt;I have gone online but no satisfying solution&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Background of the problem:&lt;/DIV&gt;&lt;DIV&gt;the variables &lt;EM&gt;&lt;STRONG&gt;not_hour, not_min, arr_hour, arr_min, hosp_hr, &lt;/STRONG&gt;&lt;/EM&gt;and &lt;EM&gt;&lt;STRONG&gt;hosp_mn&lt;/STRONG&gt;&lt;/EM&gt; are numbers that represent notification hour, notification minutes, arrival hour, arrival minute., hospital arrival hour and hospital arrival minute, respecctively.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The hour column is coded 0-24. 88 to 99 represents unknown&lt;/DIV&gt;&lt;DIV&gt;The minute column is coded 0-60. 88-99 represents unknown.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;My plan is to&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;1. concatenate the associated hour and minute columns (i.e.:&lt;EM&gt;&lt;STRONG&gt;not_hour &lt;/STRONG&gt;&lt;/EM&gt;&amp;amp;&lt;EM&gt;&lt;STRONG&gt; not_min &lt;/STRONG&gt;&lt;/EM&gt;= notification time in HH:MM&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arr_hour &lt;/STRONG&gt;&lt;/EM&gt;&amp;amp;&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp; arr_min &lt;/STRONG&gt;&lt;/EM&gt;= arrival time in HH:MM&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;hosp_hr&amp;nbsp; &lt;/STRONG&gt;&lt;/EM&gt;&amp;amp;&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;hosp_mn &lt;/STRONG&gt;&lt;/EM&gt;= hospital arrival time in HH:MM)&lt;/DIV&gt;&lt;DIV&gt;2. make them into a time format (in HH:MM)&lt;/DIV&gt;&lt;DIV&gt;3. generate time duration from them (e.g. hospital time - notification time)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;So far, all worked well!&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;But the WHERE syntax that I am using to exclude variables that have values above 0-24 in the hour column and 0-60 in the minute column is not responding.&lt;/DIV&gt;&lt;DIV&gt;I still have inappropriate values despite the WHERE syntax&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Please can you help take a look at the code?&lt;/DIV&gt;&lt;DIV&gt;Thanks&lt;/DIV&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data R11time;
set R11a;
cnot_hour= put(not_hour,z2.);
cnot_min= put(not_min,z2.);
not_tim= cat(cnot_hour,cnot_min);
   where (not_hour &amp;gt;=1 and not_hour &amp;lt;=24);
   where (not_min &amp;gt;=0 and not_min &amp;lt;=60);
nottime=input(not_tim,hhmmss4.);
  format nottime time5.;
  drop cnot_hour cnot_min not_tim;
carr_hour= put(arr_hour,z2.);
carr_min= put(arr_min,z2.);
arr_tim= cat(carr_hour,carr_min);
   where (arr_hour &amp;gt;=1 and arr_hour &amp;lt;=24);
   where (arr_min &amp;gt;=0 and arr_min &amp;lt;=60);
arrtime=input(arr_tim,hhmmss4.);
  format arrtime time5.;
  drop carr_hour carr_min arr_tim;
chosp_hr= put(hosp_hr,z2.);
chosp_mn= put(hosp_mn,z2.);
hosp_tim= cat(chosp_hr,chosp_mn);
  where (hosp_hr &amp;gt;=1 and hosp_hr &amp;lt;=24);
  where (hosp_mn &amp;gt;=0 and hosp_mn &amp;lt;=60);
hosptime=input(hosp_tim,hhmmss4.);
  format hosptime time5.;
  drop chosp_hr chosp_mn hosp_tim;
tan = (nottime - actime)/60;
tasa = (arrtime - actime)/60;
taha = (hosptime - actime)/60;
tnsa = (arrtime - nottime)/60;
tnha = (hosptime - nottime)/60;
tsaha = (hosptime - arrtime)/60;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2019 21:34:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/WHERE-syntax-How-to-appropriately-use-it-in-excluding-mutiple/m-p/577541#M13226</guid>
      <dc:creator>oadeyemi</dc:creator>
      <dc:date>2019-07-29T21:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE syntax: How to appropriately use it in excluding mutiple variables needed for a data step</title>
      <link>https://communities.sas.com/t5/New-SAS-User/WHERE-syntax-How-to-appropriately-use-it-in-excluding-mutiple/m-p/577546#M13227</link>
      <description>&lt;P&gt;Only one where condition in a data step will be effective, namely the last one. Combine all your where conditions into one with &lt;FONT face="courier new,courier"&gt;and&lt;/FONT&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2019 21:42:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/WHERE-syntax-How-to-appropriately-use-it-in-excluding-mutiple/m-p/577546#M13227</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-07-29T21:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE syntax: How to appropriately use it in excluding mutiple variables needed for a data step</title>
      <link>https://communities.sas.com/t5/New-SAS-User/WHERE-syntax-How-to-appropriately-use-it-in-excluding-mutiple/m-p/577551#M13230</link>
      <description>&lt;P&gt;There are a few basic concepts about a WHERE statement that you need to know.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, when you use multiple WHERE statements, each one replaces the ones before.&amp;nbsp; So the last WHERE statement is the only one that has any impact.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, WHERE screens out the entire observation from all processing.&amp;nbsp; So if HOSP_MIN = 80, that observation is excluded from all the calculations, including the calculations for NOTTIME and ARRTIME.&amp;nbsp; Is that your intention?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is conceivable that IF THEN statements would be more suitable.&amp;nbsp; For example you now have:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
hosp_tim= cat(chosp_hr,chosp_mn);
  where (hosp_hr &amp;gt;=1 and hosp_hr &amp;lt;=24);
  where (hosp_mn &amp;gt;=0 and hosp_mn &amp;lt;=60);
hosptime=input(hosp_tim,hhmmss4.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It might be that you would prefer to use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if (hosp_hr &amp;gt;=1 and hosp_hr &amp;lt;=24)
and (hosp_mn &amp;gt;=0 and hosp_mn &amp;lt;=60)
then do;
   hosp_tim= cat(chosp_hr,chosp_mn);
   hosptime=input(hosp_tim,hhmmss4.);
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2019 21:48:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/WHERE-syntax-How-to-appropriately-use-it-in-excluding-mutiple/m-p/577551#M13230</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-07-29T21:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE syntax: How to appropriately use it in excluding mutiple variables needed for a data step</title>
      <link>https://communities.sas.com/t5/New-SAS-User/WHERE-syntax-How-to-appropriately-use-it-in-excluding-mutiple/m-p/577555#M13232</link>
      <description>&lt;P&gt;Wow!&lt;/P&gt;&lt;P&gt;Thanks for your quick response.&lt;/P&gt;&lt;P&gt;It worked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had tried writing all the WHERE's in one line but I was using an OR ..and it makes sense, OR will not pick all the columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I noticed that after using 'and' more than once, the color changes from blue to the variable color. I guess that doen not matter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A proc univariate showed that the ranges are within the expected values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2019 21:59:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/WHERE-syntax-How-to-appropriately-use-it-in-excluding-mutiple/m-p/577555#M13232</guid>
      <dc:creator>oadeyemi</dc:creator>
      <dc:date>2019-07-29T21:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE syntax: How to appropriately use it in excluding mutiple variables needed for a data step</title>
      <link>https://communities.sas.com/t5/New-SAS-User/WHERE-syntax-How-to-appropriately-use-it-in-excluding-mutiple/m-p/578644#M13379</link>
      <description>Thank you for your comment. The if statement also works. But I will prefer excluding the missing variables entirely across board. Thank you so much for the explanation.</description>
      <pubDate>Fri, 02 Aug 2019 09:14:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/WHERE-syntax-How-to-appropriately-use-it-in-excluding-mutiple/m-p/578644#M13379</guid>
      <dc:creator>oadeyemi</dc:creator>
      <dc:date>2019-08-02T09:14:08Z</dc:date>
    </item>
  </channel>
</rss>

