<?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 clause operator incompatible variables in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/where-clause-operator-incompatible-variables/m-p/553112#M9318</link>
    <description>&lt;P&gt;it is still showing error.&lt;/P&gt;</description>
    <pubDate>Tue, 23 Apr 2019 03:12:02 GMT</pubDate>
    <dc:creator>Sathiskumar_D</dc:creator>
    <dc:date>2019-04-23T03:12:02Z</dc:date>
    <item>
      <title>where clause operator incompatible variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/where-clause-operator-incompatible-variables/m-p/553108#M9316</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options symbolgen mlogic;

%macro accountreport (State=,Age=,Last_Tran_Date=);
%let title=Detail Listing of Account;
data profile3;
set myprj2.profile2 (Keep=Acct_ID Name birthday State Balance Last_Tran_Date);
Age=((int(today()-birthday)/365.25));
format Last_Tran_Date year4.;
run;

/*proc contents data=profile3;
run;*/
proc summary data=profile3;
where Age="&amp;amp;Age" and Last_Tran_Date="&amp;amp;Last_Tran_Date";
var Acct_ID Name Age Balance Last_Tran_Date;
output out=summarized_data
sum=Balance;
run;
proc print data=summarized_data;
title "&amp;amp;title";
run;
%mend accountreport;

%accountreport(Last_Tran_Date=2015);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I don't understand the error message.I checked the proc contents too..&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2019 02:56:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/where-clause-operator-incompatible-variables/m-p/553108#M9316</guid>
      <dc:creator>Sathiskumar_D</dc:creator>
      <dc:date>2019-04-23T02:56:44Z</dc:date>
    </item>
    <item>
      <title>Re: where clause operator incompatible variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/where-clause-operator-incompatible-variables/m-p/553111#M9317</link>
      <description>&lt;P&gt;I assume that the variable Age is numeric and that the variable&amp;nbsp;Last_Tran_Date is as SAS date. Then this where statement is not correct. You can't compare string variables to numeric variables.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where Age="&amp;amp;Age" and Last_Tran_Date="&amp;amp;Last_Tran_Date";&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So, remove the quotes around your macro variables. Also, you accept what I guess is a year for the last_tran_date, but you have to make sure to compare the date with a year. You can use the year function for this. It should probably look something like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where &lt;BR /&gt;Age=&amp;amp;Age and &lt;BR /&gt;year(Last_Tran_Date) = &amp;amp;Last_Tran_Date;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Of course, you also have to make sure that there is a value for both age and last_tran_date. Possibly by adding it in the header.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro accountreport (State=,Age=.,Last_Tran_Date=.);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2019 03:07:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/where-clause-operator-incompatible-variables/m-p/553111#M9317</guid>
      <dc:creator>heffo</dc:creator>
      <dc:date>2019-04-23T03:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: where clause operator incompatible variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/where-clause-operator-incompatible-variables/m-p/553112#M9318</link>
      <description>&lt;P&gt;it is still showing error.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2019 03:12:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/where-clause-operator-incompatible-variables/m-p/553112#M9318</guid>
      <dc:creator>Sathiskumar_D</dc:creator>
      <dc:date>2019-04-23T03:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: where clause operator incompatible variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/where-clause-operator-incompatible-variables/m-p/553114#M9319</link>
      <description>&lt;P&gt;What is the error? Did you run the whole code, including the macro definition (%macro to %mend) to make sure you have recompiled the macro?&lt;/P&gt;&lt;P&gt;Would there be any results when you have age as missing and the year set to 2015?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2019 03:15:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/where-clause-operator-incompatible-variables/m-p/553114#M9319</guid>
      <dc:creator>heffo</dc:creator>
      <dc:date>2019-04-23T03:15:45Z</dc:date>
    </item>
    <item>
      <title>Re: where clause operator incompatible variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/where-clause-operator-incompatible-variables/m-p/553115#M9320</link>
      <description>&lt;P&gt;variable name in the list does not match type prescribed in this list..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does it mean var statement will not accept any char variable???&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2019 03:18:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/where-clause-operator-incompatible-variables/m-p/553115#M9320</guid>
      <dc:creator>Sathiskumar_D</dc:creator>
      <dc:date>2019-04-23T03:18:06Z</dc:date>
    </item>
    <item>
      <title>Re: where clause operator incompatible variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/where-clause-operator-incompatible-variables/m-p/553121#M9321</link>
      <description>&lt;P&gt;Yes..I did..It is still showing error&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2019 03:52:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/where-clause-operator-incompatible-variables/m-p/553121#M9321</guid>
      <dc:creator>Sathiskumar_D</dc:creator>
      <dc:date>2019-04-23T03:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: where clause operator incompatible variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/where-clause-operator-incompatible-variables/m-p/553122#M9322</link>
      <description>That's right.  SAS won't try to compute the sum of a character variable.  If you ask for that, you get an error message.</description>
      <pubDate>Tue, 23 Apr 2019 03:53:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/where-clause-operator-incompatible-variables/m-p/553122#M9322</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-04-23T03:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: where clause operator incompatible variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/where-clause-operator-incompatible-variables/m-p/553123#M9323</link>
      <description>&lt;P&gt;I need the sum for balance not for any character variable..&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2019 03:56:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/where-clause-operator-incompatible-variables/m-p/553123#M9323</guid>
      <dc:creator>Sathiskumar_D</dc:creator>
      <dc:date>2019-04-23T03:56:45Z</dc:date>
    </item>
    <item>
      <title>Re: where clause operator incompatible variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/where-clause-operator-incompatible-variables/m-p/553124#M9324</link>
      <description>Then why add all those other variables to the VAR statement?  What are you trying to accomplish by doing that?</description>
      <pubDate>Tue, 23 Apr 2019 04:05:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/where-clause-operator-incompatible-variables/m-p/553124#M9324</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-04-23T04:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: where clause operator incompatible variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/where-clause-operator-incompatible-variables/m-p/553327#M9357</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/120805"&gt;@Sathiskumar_D&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;variable name in the list does not match type prescribed in this list..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does it mean var statement will not accept any char variable???&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Post the log with the errors. Since you are working with macro code you should set the option mprint before executing the macro to get more context on the error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Options mprint;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token macroname"&gt;%accountreport&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;Last_Tran_Date&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2015&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;Then go to the LOG and copy the generated code from the start of the lines that show MPRINT though to the end. Paste the copied code into a code box opened with the forum's {I} icon or "running man".&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;You may need to provide the results of Proc Contents on your data set as well since your code expects one type of variable and your data appears to not match that.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;Proc summary will only accept NUMERIC variables on the VAR statement.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;I am suspecting that you may have wanted something more like&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;proc summary data=profile3 nway;
   where Age=&amp;amp;Age and year(Last_Tran_Date)=&amp;amp;Last_Tran_Date.;
   class  Acct_ID Name Age Last_Tran_Date;

   var  Balance ;
   output out=summarized_data
        sum=Balance;
run;
&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;If the intent was to get a sum for the combinations of Acct_id Name&amp;nbsp;and Age Last_Tran_date.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;If last_tran_date or age are NOT character variables then do not use quotes around them.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;If last_tran_date is an actual date your where statement probable should look like:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;where age=&amp;amp;age. and year(last_tran_date) = &amp;amp;last_tran_date. ;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;SAS does not use a formatted value for comparisons unless you force it using Put(variable, format.) = "somevalue"&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2019 16:11:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/where-clause-operator-incompatible-variables/m-p/553327#M9357</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-23T16:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: where clause operator incompatible variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/where-clause-operator-incompatible-variables/m-p/553457#M9389</link>
      <description>&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options symbolgen mlogic;

%macro accountreport (State=,Age=,Last_Tran_Date=);
%let title=Detail Listing of Account;
data profile3;
set myprj2.profile2 (keep=Acct_ID Name Birthday State Balance Last_Tran_Date);
Age=((int(today()-birthday)/365.25));
/*birthdate=input(birthday,mmddyy10.);*/
format Last_Tran_Date year4.
		Age 3.0
		Birthday best.;/*stored in numeric format*/
run;
/*proc print data=profile3;
run;*/
/*proc contents data=profile3;
run;*/
proc print data=profile3;
var Acct_ID Name Age Balance Last_Tran_Date; 
sum Balance;
where Age=&amp;amp;Age and year(Last_Tran_Date)=&amp;amp;Last_Tran_Date;
title &amp;amp;title;
run;
%mend accountreport;

options mprint;
%accountreport(Last_Tran_Date=2015);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is still showing ERROR!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2019 22:41:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/where-clause-operator-incompatible-variables/m-p/553457#M9389</guid>
      <dc:creator>Sathiskumar_D</dc:creator>
      <dc:date>2019-04-23T22:41:04Z</dc:date>
    </item>
  </channel>
</rss>

