<?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 Where clause requires a compatible variable. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Where-clause-requires-a-compatible-variable/m-p/804211#M316669</link>
    <description>&lt;P&gt;Hello team,&lt;/P&gt;
&lt;PRE&gt;data mydata (keep = plan id  orderenddate year month);
set mydata1;
year = year(orderenddate);
month = month(oorderenddate);
run;

/*Year and months are not in dataset, I added them for the functions that I have use*/

data mydata2;
set mydata1;
where year =2022;
run;&lt;/PRE&gt;
&lt;P&gt;where year = 2022 give errors. orderenddate is numeric data type which is formatted as a date in dataset: 2022-03-13.&lt;/P&gt;
&lt;P&gt;How can I overcome this error?&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;b&amp;amp;b&lt;/P&gt;</description>
    <pubDate>Sat, 26 Mar 2022 03:02:44 GMT</pubDate>
    <dc:creator>GN0001</dc:creator>
    <dc:date>2022-03-26T03:02:44Z</dc:date>
    <item>
      <title>Where clause requires a compatible variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-clause-requires-a-compatible-variable/m-p/804211#M316669</link>
      <description>&lt;P&gt;Hello team,&lt;/P&gt;
&lt;PRE&gt;data mydata (keep = plan id  orderenddate year month);
set mydata1;
year = year(orderenddate);
month = month(oorderenddate);
run;

/*Year and months are not in dataset, I added them for the functions that I have use*/

data mydata2;
set mydata1;
where year =2022;
run;&lt;/PRE&gt;
&lt;P&gt;where year = 2022 give errors. orderenddate is numeric data type which is formatted as a date in dataset: 2022-03-13.&lt;/P&gt;
&lt;P&gt;How can I overcome this error?&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;b&amp;amp;b&lt;/P&gt;</description>
      <pubDate>Sat, 26 Mar 2022 03:02:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-clause-requires-a-compatible-variable/m-p/804211#M316669</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2022-03-26T03:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: Where clause requires a compatible variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-clause-requires-a-compatible-variable/m-p/804215#M316672</link>
      <description>&lt;P&gt;Read the dataset you added them to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mydata2;
set mydata; * You created them in mydata not mydata1;
where year =2022;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 26 Mar 2022 04:29:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-clause-requires-a-compatible-variable/m-p/804215#M316672</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-03-26T04:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: Where clause requires a compatible variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-clause-requires-a-compatible-variable/m-p/804225#M316678</link>
      <description>&lt;P&gt;I believe we have asked that when there are errors to copy the log with procedure or data step code and all of the note, warnings and errors; open a text box on the forum using the &amp;lt;/&amp;gt; icon and paste the text with all of that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Don't make us guess what the error is or where it occurs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may also want to run proc contents on your data set and show us the results.&lt;/P&gt;</description>
      <pubDate>Sat, 26 Mar 2022 05:21:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-clause-requires-a-compatible-variable/m-p/804225#M316678</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-26T05:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: Where clause requires a compatible variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-clause-requires-a-compatible-variable/m-p/804232#M316685</link>
      <description>&lt;P&gt;Use IF statement it converts any data type num to char and char to num this is the one&amp;nbsp; difference between&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IF &amp;amp; Where&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where can not convert char to numeric&lt;/P&gt;</description>
      <pubDate>Sat, 26 Mar 2022 06:23:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-clause-requires-a-compatible-variable/m-p/804232#M316685</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2022-03-26T06:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: Where clause requires a compatible variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-clause-requires-a-compatible-variable/m-p/804241#M316692</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265860"&gt;@BrahmanandaRao&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Use IF statement it converts any data type num to char and char to num this is the one&amp;nbsp; difference between&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IF &amp;amp; Where&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where can not convert char to numeric&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;But you can put functions in Where statements such as&lt;/P&gt;
&lt;PRE&gt;where year(somedatevariable)= 2022;&lt;/PRE&gt;
&lt;P&gt;Unless that "year" variable is to be used for something else it is not even needed.&lt;/P&gt;
&lt;P&gt;Many times when you need a "year" variable it may be quite possible that applying the YEAR format to a date variable will suffice.&lt;/P&gt;</description>
      <pubDate>Sat, 26 Mar 2022 08:10:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-clause-requires-a-compatible-variable/m-p/804241#M316692</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-26T08:10:23Z</dc:date>
    </item>
  </channel>
</rss>

