<?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: ERROR: Required operator not found in expression in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Required-operator-not-found-in-expression/m-p/916810#M361119</link>
    <description>&lt;P&gt;Clean up some of the other issues and see if it helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example the TRIM() function is not doing anything here:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select trim(lowcase(a.pricing_plan_id)) as pricing_plan_id length=37&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;TRIM() just removes the trailing spaces and they will be added back when the value is stored so that PRICING_PLAN_ID is padded to its full 37 byte length.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And all of those INPUT() function calls like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input(b.rule_val_1404,1.)
input(b.rule_val_1304,best9.)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;First don't use BEST as if it meant something special as an INFORMAT.&amp;nbsp; BEST is the name of a FORMAT that tries to find the "best" way to display a number in a fixed number of characters.&amp;nbsp; But there is no similar concept for making a number from a string.&amp;nbsp; There is only one way to store a number in SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then INPUT() function does not care if the WIDTH you use on the INFORMAT specification is larger than the LENGTH of the string being read&amp;nbsp; So unless there are characters past the first byte of&amp;nbsp;rule_val_1404 or the ninth byte of&amp;nbsp;rule_val_1404 you want to ignore then just use width of 32 which is the maximum that the numeric informat supports.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also using short widths on the informats might cause trouble if the character string has leading spaces.&amp;nbsp; What if you had these strings for those two variables?&amp;nbsp; Your INPUT() function calls would return missing value as the result.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;rule_val_1404 = '     1' ;
rule_val_1304 ='          12';
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you are not sure how messy the character variables are you might want to use LEFT() function to remove the leading spaces before converting them into numbers.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input(left(b.rule_val_1404),32.)
input(left(b.rule_val_1304),32.)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 19 Feb 2024 15:53:49 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-02-19T15:53:49Z</dc:date>
    <item>
      <title>ERROR: Required operator not found in expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Required-operator-not-found-in-expression/m-p/916431#M360971</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone please help me in the condition check, for a particular condition check using %if I am getting below issue&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%if input(b.rule_val_1526,1.) = 1 %then %do;&lt;BR /&gt;input(b.rule_val_1503,best18.) as gross_margin_lb_promo format=&amp;amp;gv_rd_amt_sas_format.,&lt;BR /&gt;input(b.rule_val_1504,best18.) as gross_margin_ub_promo format=&amp;amp;gv_rd_amt_sas_format.,&lt;BR /&gt;%end;&lt;BR /&gt;%else %if input(b.rule_val_1526,1.) = 0 or input(b.rule_val_1526,1.) = . %then %do;&lt;BR /&gt;. as gross_margin_lb_promo format=&amp;amp;gv_rd_amt_sas_format., &lt;BR /&gt;. as gross_margin_ub_promo format=&amp;amp;gv_rd_amt_sas_format.,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Required operator not found in expression: input(b.rule_val_1526,1) = 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What went wrong in the condition check..&lt;/P&gt;
&lt;P&gt;the table b is having rule_val_1526 column and data format is char&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 12:52:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Required-operator-not-found-in-expression/m-p/916431#M360971</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2024-02-16T12:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Required operator not found in expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Required-operator-not-found-in-expression/m-p/916433#M360973</link>
      <description>&lt;PRE&gt;ERROR: Required operator not found in expression: input(b.rule_val_1526,1) = 1&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second argument of the &lt;A href="https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lefunctionsref/p19en16vskd2vhn1vwmxpxnglxxs.htm" target="_self"&gt;INPUT function&lt;/A&gt; must be an informat. You do not have an informat as the second argument according to this ERROR message. Perhaps you want this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input(b.rule_val_1526,1.)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;now the second argument is an informat (might not be the right informat, that's up to you). But, code like this will probably never work&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if input(b.rule_val_1526,1.) = 1 %then %do;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;because the %IF function treats the&amp;nbsp;&lt;FONT face="courier new,courier"&gt;input(b.rule_val_1526,1.) = 1&lt;/FONT&gt; as text, not as a logical comparison of two values, and that's probably not what you want. In fact, since this piece of code is embedded in PROC SQL, there is no way for a macro %IF to access the values of b.rule_val_1526 to execute this %IF. Perhaps you want the input() function to be in a CASE WHEN rather than in an %IF statement.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 13:26:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Required-operator-not-found-in-expression/m-p/916433#M360973</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-02-16T13:26:12Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Required operator not found in expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Required-operator-not-found-in-expression/m-p/916480#M360981</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:
&lt;P&gt;... the %IF function treats the&amp;nbsp;&lt;FONT face="courier new,courier"&gt;input(b.rule_val_1526,1.) = 1&lt;/FONT&gt; as text, not as a logical comparison of two values, ...&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Just as a side note: I think, technically, the macro processor &lt;EM&gt;does&lt;/EM&gt; try to interpret this %IF condition as a (nonsensical) comparison of two values, but complains about the missing "required operator" on the left-hand side between the word "&lt;FONT face="courier new,courier"&gt;input&lt;/FONT&gt;" and the text expression "&lt;FONT face="courier new,courier"&gt;b.rule_val_1526,1.&lt;/FONT&gt;" in parentheses. With an inserted operator such as an equal sign or without the parentheses that particular error message would not occur.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 14:44:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Required-operator-not-found-in-expression/m-p/916480#M360981</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-02-16T14:44:27Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Required operator not found in expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Required-operator-not-found-in-expression/m-p/916610#M361007</link>
      <description>thanks, it is giving same error %if input(b.rule_val_1526,1.) = 1 %then %do;&lt;BR /&gt;I think I need to post while proc sql query. I got to know that if condition can't be used inside proc sql.</description>
      <pubDate>Sat, 17 Feb 2024 05:58:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Required-operator-not-found-in-expression/m-p/916610#M361007</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2024-02-17T05:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Required operator not found in expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Required-operator-not-found-in-expression/m-p/916611#M361008</link>
      <description>Thanks for suggesting . it's not working like that &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; too</description>
      <pubDate>Sat, 17 Feb 2024 05:59:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Required-operator-not-found-in-expression/m-p/916611#M361008</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2024-02-17T05:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Required operator not found in expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Required-operator-not-found-in-expression/m-p/916612#M361009</link>
      <description>proc sql noprint;&lt;BR /&gt;            create table &amp;amp;abt_worklib..input_plan_rules_1&lt;BR /&gt;            as&lt;BR /&gt;            select      trim(lowcase(a.pricing_plan_id)) as pricing_plan_id length=37,  &lt;BR /&gt;                        trim(lowcase(a.business_category_id)) as business_category_id label='business_category_id' length=37,&lt;BR /&gt;                        &amp;amp;gv_current_dt. as current_date format=&amp;amp;gv_rd_date_sas_format. label='current_date',&lt;BR /&gt;                        %if %length(&amp;amp;init_rec_promo_dt) eq 0 %then %do; &lt;BR /&gt;                           . as initial_rec_date_promo format=&amp;amp;gv_rd_date_sas_format. label='initial_rec_date_promo',&lt;BR /&gt;                        %end;&lt;BR /&gt;                        %else %do;&lt;BR /&gt;                           &amp;amp;init_rec_promo_dt. as initial_rec_date_promo format=&amp;amp;gv_rd_date_sas_format. label='initial_rec_date_promo',&lt;BR /&gt;                        %end;&lt;BR /&gt;                        %if %length(&amp;amp;last_rec_dt_promo) eq 0 %then %do; &lt;BR /&gt;                          . as last_rec_date_promo format=&amp;amp;gv_rd_date_sas_format. label='last_rec_date_promo',&lt;BR /&gt;                        %end;&lt;BR /&gt;                        %else %do;&lt;BR /&gt;                          &amp;amp;last_rec_dt_promo. as last_rec_date_promo format=&amp;amp;gv_rd_date_sas_format. label='last_rec_date_promo',&lt;BR /&gt;                        %end;&lt;BR /&gt;                        /*2 as opt_flag format=1. length=3,*/&lt;BR /&gt;                        &amp;amp;opt_flag. as opt_flag format=1. length=3,&lt;BR /&gt;                        '' as promo_period length=500 informat=$500. format=$500.,&lt;BR /&gt;                        case when input(b.rule_val_1525,1.) = 0 then 5&lt;BR /&gt;                             when input(b.rule_val_1525,1.) = 1 then 4&lt;BR /&gt;                             when input(b.rule_val_1525,1.) = 2 then 1&lt;BR /&gt;                             else 0 end as obj_func_promo format=3. length=3,&lt;BR /&gt;                        input(b.rule_val_1404,1.) as promo_price_grid_type format=1. length=3,&lt;BR /&gt;                        input(b.rule_val_1301,1.) as is_inventory_constrained format=1. length=3,&lt;BR /&gt;                        input(b.rule_val_1302,best9.) as min_discount_pct_promo format=&amp;amp;gv_rd_pct_sas_format.,&lt;BR /&gt;                        input(b.rule_val_1303,best9.) as max_discount_pct_promo format=&amp;amp;gv_rd_pct_sas_format.,&lt;BR /&gt;                        case when input(b.rule_val_1306,1.) = 1 then input(b.rule_val_1304,best9.)&lt;BR /&gt;                            else . end as min_margin_pct_promo format=&amp;amp;gv_rd_pct_sas_format.,&lt;BR /&gt;                        case when input(b.rule_val_1306,1.) = 2 then input(b.rule_val_1304,best18.)&lt;BR /&gt;                            else . end as min_margin_promo format=&amp;amp;gv_rd_amt_sas_format.,&lt;BR /&gt;                        case when input(b.rule_val_1306,1.) = 1 then input(b.rule_val_1305,best9.)&lt;BR /&gt;                            else . end as max_margin_pct_promo format=&amp;amp;gv_rd_pct_sas_format.,&lt;BR /&gt;                        case when input(b.rule_val_1306,1.) = 2 then input(b.rule_val_1305,best18.)&lt;BR /&gt;                            else . end as max_margin_promo format=&amp;amp;gv_rd_amt_sas_format.,&lt;BR /&gt;                        %if input(b.rule_val_1526,1.) = 1  %then %do;&lt;BR /&gt;                            input(b.rule_val_1503,best18.) as gross_margin_lb_promo format=&amp;amp;gv_rd_amt_sas_format.,&lt;BR /&gt;                             input(b.rule_val_1504,best18.) as gross_margin_ub_promo format=&amp;amp;gv_rd_amt_sas_format.,&lt;BR /&gt;                        %end;&lt;BR /&gt;                        %else %if input(b.rule_val_1526,1.) = 0  or input(b.rule_val_1526,1.) = . %then %do;&lt;BR /&gt;                             .  as gross_margin_lb_promo format=&amp;amp;gv_rd_amt_sas_format., &lt;BR /&gt;                             .  as gross_margin_ub_promo format=&amp;amp;gv_rd_amt_sas_format., &lt;BR /&gt;                        %end;&lt;BR /&gt;                        %if input(b.rule_val_1527,1.) = 1  %then %do;&lt;BR /&gt;                             input(b.rule_val_1505,best12.) as sell_through_units_lb_promo format=&amp;amp;gv_rd_qty_sas_format.,&lt;BR /&gt;                             input(b.rule_val_1506,best12.) as sell_through_units_ub_promo format=&amp;amp;gv_rd_qty_sas_format.,&lt;BR /&gt;                         %end;&lt;BR /&gt;                         %else %if input(b.rule_val_1527,1.) = 0  or input(b.rule_val_1527,1.) = . %then %do;&lt;BR /&gt;                             .  as sell_through_units_lb_promo format=&amp;amp;gv_rd_qty_sas_format., &lt;BR /&gt;                             .  as sell_through_units_ub_promo format=&amp;amp;gv_rd_qty_sas_format., &lt;BR /&gt;                        %end;&lt;BR /&gt;                        %if input(b.rule_val_1528,1.) = 1  %then %do;&lt;BR /&gt;                            input(b.rule_val_1501,best18.) as gross_margin_lb_promo format=&amp;amp;gv_rd_amt_sas_format.,&lt;BR /&gt;                             input(b.rule_val_1502,best18.) as gross_margin_ub_promo format=&amp;amp;gv_rd_amt_sas_format.,&lt;BR /&gt;                       %end;&lt;BR /&gt;                       %else %if input(b.rule_val_1528,1.) = 2  %then %do;&lt;BR /&gt;                          input(b.rule_val_1507,best9.) as gross_margin_pct_lb_promo format=&amp;amp;gv_rd_qty_sas_format.,&lt;BR /&gt;                          input(b.rule_val_1508,best9.) as gross_margin_pct_ub_promo format=&amp;amp;gv_rd_qty_sas_format.,&lt;BR /&gt;                       %end;&lt;BR /&gt;                        %else %if input(b.rule_val_1528,1.) = 0 or input(b.rule_val_1528,1.) = . %then %do;&lt;BR /&gt;                        .  as gross_margin_lb_promo format=&amp;amp;gv_rd_amt_sas_format., &lt;BR /&gt;                        .  as gross_margin_ub_promo format=&amp;amp;gv_rd_amt_sas_format., &lt;BR /&gt;                        .  as gross_margin_pct_lb_promo format=&amp;amp;gv_rd_qty_sas_format.,&lt;BR /&gt;                        . as gross_margin_pct_ub_promo format=&amp;amp;gv_rd_qty_sas_format.,&lt;BR /&gt;                        %end;                  &lt;BR /&gt;                        1 as allow_manual_mkd format=1. length=3,                        &lt;BR /&gt;                        1 as allow_manual_promo_on_reg_price format=1. length=3,&lt;BR /&gt;                        1 as allow_stacked_promo_on_mkd format=1. length=3,            &lt;BR /&gt;                        1 as allow_stacked_promo_on_promo format=1. length=3,&lt;BR /&gt;                        1 as allow_promo_price_below_mpp format=1. length=3                     &lt;BR /&gt;                        /*input(b.rule_val_516,6.) as min_periods_since_avail_dt format=&amp;amp;gv_rd_cnt_sas_format.*/&lt;BR /&gt;            from        &amp;amp;abt_worklib..pricing_plan a&lt;BR /&gt;&lt;BR /&gt;            left join   &amp;amp;abt_worklib..plan_rule_transposed b&lt;BR /&gt;                    on upcase(a.pricing_plan_id) = upcase(b.pricing_plan_id)&lt;BR /&gt;        &lt;BR /&gt;            left join   &amp;amp;pricing_lib..date_dm e&lt;BR /&gt;                    on a.end_dt between e.fiscal_start_dt and e.fiscal_end_dt&lt;BR /&gt;                    and e.date_lvl_no = &amp;amp;time_low_lvl.&lt;BR /&gt;        ;&lt;BR /&gt;       quit;&lt;BR /&gt;    %end;</description>
      <pubDate>Sat, 17 Feb 2024 06:00:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Required-operator-not-found-in-expression/m-p/916612#M361009</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2024-02-17T06:00:19Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Required operator not found in expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Required-operator-not-found-in-expression/m-p/916614#M361010</link>
      <description>&lt;P&gt;What you are principally missing: Anything SAS Macro language will pre-process before your Proc SQL even starts running.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS Macro language is mainly used to dynamically create SAS code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What you are trying to do is to define a condition in macro language that uses data from your Proc SQL. But when the macro code executes (which is only textual) the macro processor won't know anything about your SQL variables. It will just execute the macro level logic and the leave some SAS/SQL level code. Then the SAS processor comes and will execute this code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On top of it: You can't use SAS functions directly on macro level. You do need to instruct the macro processor to call the SAS function via %sysfunc(&amp;lt;SAS function&amp;gt;).&lt;/P&gt;
&lt;P&gt;But again: Even you'd wrap a %sysfunc() around the input function there won't be an column b.rule_val_1526 available. On a macro level the macro processor would just treat it as a string.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1708150803106.png" style="width: 724px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/93889iDF268420670754F6/image-dimensions/724x114?v=v2" width="724" height="114" role="button" title="Patrick_0-1708150803106.png" alt="Patrick_0-1708150803106.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to revamp your logic. If you want the SQL to return values based on some other column then use a SQL CASE statement.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Feb 2024 06:25:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Required-operator-not-found-in-expression/m-p/916614#M361010</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-02-17T06:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Required operator not found in expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Required-operator-not-found-in-expression/m-p/916616#M361011</link>
      <description>&lt;P&gt;Get rid of all the macro code and use &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/sqlproc/n0a85s0ijz65irn1h3jtariooea5.htm" target="_blank" rel="noopener"&gt;CASE - WHEN - THEN - ELSE - END&lt;/A&gt; logic, as this is the method SQL provides for conditional evaluation.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Feb 2024 07:30:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Required-operator-not-found-in-expression/m-p/916616#M361011</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-02-17T07:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Required operator not found in expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Required-operator-not-found-in-expression/m-p/916622#M361017</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/327170"&gt;@Aexor&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;thanks, it is giving same error %if input(b.rule_val_1526,1.) = 1 %then %do;&lt;BR /&gt;I think I need to post while proc sql query. I got to know that if condition can't be used inside proc sql.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Perhaps you didn't read the rest of my post. I explained how&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%if input(b.rule_val_1526,1.) = 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;cannot work and do what you want because %IF cannot access the values of data set variables such as b.rule_val_1526 and that you need to use CASE WHEN instead of %IF&lt;/P&gt;</description>
      <pubDate>Sat, 17 Feb 2024 12:28:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Required-operator-not-found-in-expression/m-p/916622#M361017</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-02-17T12:28:53Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Required operator not found in expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Required-operator-not-found-in-expression/m-p/916633#M361022</link>
      <description>&lt;P&gt;That cannot work as the macro processor will work BEFORE the generated SQL code starts to run.&amp;nbsp; So the %IF statements cannot base their decision on the values of variables in datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is not clear what those %IF statements are trying to do but perhaps you can re work them to be more like this block that is NOT trying to reference the values of dataset variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %length(&amp;amp;last_rec_dt_promo) eq 0 %then %do;
. as last_rec_date_promo format=&amp;amp;gv_rd_date_sas_format. label='last_rec_date_promo',
%end;
%else %do;
&amp;amp;last_rec_dt_promo. as last_rec_date_promo format=&amp;amp;gv_rd_date_sas_format. label='last_rec_date_promo',
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Put it might be easier to just do:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %length(&amp;amp;last_rec_dt_promo) eq 0 %then %do;
  %let last_rec_dt_promo=.;
%end;
&amp;amp;last_rec_dt_promo. as last_rec_date_promo format=&amp;amp;gv_rd_date_sas_format. label='last_rec_date_promo',
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are having trouble then first make SAS code that works without any macro code.&amp;nbsp; Then you can work on using macro variables and/or macro logic to help generate the SAS code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need more help provide the two input datasets and values for the macro variables referenced. And explain what code you want the macro logic to generate.&amp;nbsp; And what result you would expect from that code for the given inputs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Feb 2024 17:07:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Required-operator-not-found-in-expression/m-p/916633#M361022</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-02-17T17:07:00Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Required operator not found in expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Required-operator-not-found-in-expression/m-p/916771#M361107</link>
      <description>Thanks. It still giving me wrong input for columns. for.eg I am getting "missing value"  for all columns where case statement is applied in 15** series</description>
      <pubDate>Mon, 19 Feb 2024 12:49:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Required-operator-not-found-in-expression/m-p/916771#M361107</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2024-02-19T12:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Required operator not found in expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Required-operator-not-found-in-expression/m-p/916773#M361109</link>
      <description>proc sql noprint;&lt;BR /&gt;            create table &amp;amp;abt_worklib..input_plan_rules_1&lt;BR /&gt;            as&lt;BR /&gt;            select      trim(lowcase(a.pricing_plan_id)) as pricing_plan_id length=37,  &lt;BR /&gt;                        trim(lowcase(a.business_category_id)) as business_category_id label='business_category_id' length=37,&lt;BR /&gt;                        &amp;amp;gv_current_dt. as current_date format=&amp;amp;gv_rd_date_sas_format. label='current_date',&lt;BR /&gt;                        %if %length(&amp;amp;init_rec_promo_dt) eq 0 %then %do; &lt;BR /&gt;                           . as initial_rec_date_promo format=&amp;amp;gv_rd_date_sas_format. label='initial_rec_date_promo',&lt;BR /&gt;                        %end;&lt;BR /&gt;                        %else %do;&lt;BR /&gt;                           &amp;amp;init_rec_promo_dt. as initial_rec_date_promo format=&amp;amp;gv_rd_date_sas_format. label='initial_rec_date_promo',&lt;BR /&gt;                        %end;&lt;BR /&gt;                        %if %length(&amp;amp;last_rec_dt_promo) eq 0 %then %do; &lt;BR /&gt;                          . as last_rec_date_promo format=&amp;amp;gv_rd_date_sas_format. label='last_rec_date_promo',&lt;BR /&gt;                        %end;&lt;BR /&gt;                        %else %do;&lt;BR /&gt;                          &amp;amp;last_rec_dt_promo. as last_rec_date_promo format=&amp;amp;gv_rd_date_sas_format. label='last_rec_date_promo',&lt;BR /&gt;                        %end;&lt;BR /&gt;                        /*2 as opt_flag format=1. length=3,*/&lt;BR /&gt;                        &amp;amp;opt_flag. as opt_flag format=1. length=3,&lt;BR /&gt;                        '' as promo_period length=500 informat=$500. format=$500.,&lt;BR /&gt;                        case when input(b.rule_val_1525,1.) = 0 then 5&lt;BR /&gt;                             when input(b.rule_val_1525,1.) = 1 then 4&lt;BR /&gt;                             when input(b.rule_val_1525,1.) = 2 then 1&lt;BR /&gt;                             else 0 end as obj_func_promo format=3. length=3,&lt;BR /&gt;                        input(b.rule_val_1404,1.) as promo_price_grid_type format=1. length=3,&lt;BR /&gt;                        input(b.rule_val_1301,1.) as is_inventory_constrained format=1. length=3,&lt;BR /&gt;                        input(b.rule_val_1302,best9.) as min_discount_pct_promo format=&amp;amp;gv_rd_pct_sas_format.,&lt;BR /&gt;                        input(b.rule_val_1303,best9.) as max_discount_pct_promo format=&amp;amp;gv_rd_pct_sas_format.,&lt;BR /&gt;                        case when input(b.rule_val_1306,1.) = 1 then input(b.rule_val_1304,best9.)&lt;BR /&gt;                            else . end as min_margin_pct_promo format=&amp;amp;gv_rd_pct_sas_format.,&lt;BR /&gt;                        case when input(b.rule_val_1306,1.) = 2 then input(b.rule_val_1304,best18.)&lt;BR /&gt;                            else . end as min_margin_promo format=&amp;amp;gv_rd_amt_sas_format.,&lt;BR /&gt;                        case when input(b.rule_val_1306,1.) = 1 then input(b.rule_val_1305,best9.)&lt;BR /&gt;                            else . end as max_margin_pct_promo format=&amp;amp;gv_rd_pct_sas_format.,&lt;BR /&gt;                        case when input(b.rule_val_1306,1.) = 2 then input(b.rule_val_1305,best18.)&lt;BR /&gt;                            else . end as max_margin_promo format=&amp;amp;gv_rd_amt_sas_format.,&lt;BR /&gt;                        case when input(b.rule_val_1526,1.) = 1 then input(b.rule_val_1503,best18.)&lt;BR /&gt;                            else . end as gross_margin_lb_promo format=&amp;amp;gv_rd_amt_sas_format.,&lt;BR /&gt;                        case when input(b.rule_val_1526,1.) = 1 then input(b.rule_val_1504,best18.)&lt;BR /&gt;                             else . end as gross_margin_ub_promo format=&amp;amp;gv_rd_amt_sas_format.,&lt;BR /&gt;                        case when input(b.rule_val_1526,1.) = 0 or input(b.rule_val_1526,1.) = . then .&lt;BR /&gt;                             else . end as gross_margin_lb_promo format=&amp;amp;gv_rd_amt_sas_format., &lt;BR /&gt;                        case when input(b.rule_val_1526,1.) = 0 or input(b.rule_val_1526,1.) = . then .&lt;BR /&gt;                            else . end as gross_margin_ub_promo format=&amp;amp;gv_rd_amt_sas_format., &lt;BR /&gt;                        case when input(b.rule_val_1527,1.) = 1 then input(b.rule_val_1505,best18.)&lt;BR /&gt;                            else . end as sell_through_units_lb_promo format=&amp;amp;gv_rd_qty_sas_format.,&lt;BR /&gt;                        case when input(b.rule_val_1527,1.) = 1 then input(b.rule_val_1506,best18.)&lt;BR /&gt;                             else . end as sell_through_units_ub_promo format=&amp;amp;gv_rd_qty_sas_format.,&lt;BR /&gt;                        case when input(b.rule_val_1527,1.) = 0 or input(b.rule_val_1527,1.) = . then .&lt;BR /&gt;                             else . end as sell_through_units_lb_promo format=&amp;amp;gv_rd_qty_sas_format., &lt;BR /&gt;                        case when input(b.rule_val_1527,1.) = 0 or input(b.rule_val_1526,1.) = . then .&lt;BR /&gt;                            else . end as sell_through_units_ub_promo format=&amp;amp;gv_rd_qty_sas_format., &lt;BR /&gt;                        case when input(b.rule_val_1528,1.) = 1 then input(b.rule_val_1501,best18.)&lt;BR /&gt;                            else . end as gross_margin_lb_promo format=&amp;amp;gv_rd_amt_sas_format.,&lt;BR /&gt;                        case when input(b.rule_val_1528,1.) = 1 then input(b.rule_val_1502,best18.)&lt;BR /&gt;                             else . end as gross_margin_ub_promo format=&amp;amp;gv_rd_amt_sas_format.,&lt;BR /&gt;                        case when input(b.rule_val_1528,1.) = 2 then input(b.rule_val_1507,best18.)&lt;BR /&gt;                             else . end as gross_margin_pct_lb_promo format=&amp;amp;gv_rd_qty_sas_format., &lt;BR /&gt;                        case when input(b.rule_val_1528,1.) = 2 then input(b.rule_val_1508,best18.)&lt;BR /&gt;                             else . end as gross_margin_pct_ub_promo format=&amp;amp;gv_rd_qty_sas_format., &lt;BR /&gt;                        case when input(b.rule_val_1528,1.) = 0 or input(b.rule_val_1528,1.) = . then .&lt;BR /&gt;                             else . end as gross_margin_pct_ub_promo format=&amp;amp;gv_rd_qty_sas_format.,                      &lt;BR /&gt;                        1 as allow_manual_mkd format=1. length=3,                        &lt;BR /&gt;                        1 as allow_manual_promo_on_reg_price format=1. length=3,&lt;BR /&gt;                        1 as allow_stacked_promo_on_mkd format=1. length=3,            &lt;BR /&gt;                        1 as allow_stacked_promo_on_promo format=1. length=3,&lt;BR /&gt;                        1 as allow_promo_price_below_mpp format=1. length=3,                        &lt;BR /&gt;                        input(b.rule_val_1508,best9.) as gross_margin_pct_ub_promo format=&amp;amp;gv_rd_qty_sas_format.&lt;BR /&gt;                        /*input(b.rule_val_516,6.) as min_periods_since_avail_dt format=&amp;amp;gv_rd_cnt_sas_format.*/&lt;BR /&gt;            from        &amp;amp;abt_worklib..pricing_plan a&lt;BR /&gt;&lt;BR /&gt;            left join   &amp;amp;abt_worklib..plan_rule_transposed b&lt;BR /&gt;                    on upcase(a.pricing_plan_id) = upcase(b.pricing_plan_id)&lt;BR /&gt;        &lt;BR /&gt;            left join   &amp;amp;pricing_lib..date_dm e&lt;BR /&gt;                    on a.end_dt between e.fiscal_start_dt and e.fiscal_end_dt&lt;BR /&gt;                    and e.date_lvl_no = &amp;amp;time_low_lvl.&lt;BR /&gt;        ;&lt;BR /&gt;       quit;</description>
      <pubDate>Mon, 19 Feb 2024 12:50:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Required-operator-not-found-in-expression/m-p/916773#M361109</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2024-02-19T12:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Required operator not found in expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Required-operator-not-found-in-expression/m-p/916810#M361119</link>
      <description>&lt;P&gt;Clean up some of the other issues and see if it helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example the TRIM() function is not doing anything here:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select trim(lowcase(a.pricing_plan_id)) as pricing_plan_id length=37&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;TRIM() just removes the trailing spaces and they will be added back when the value is stored so that PRICING_PLAN_ID is padded to its full 37 byte length.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And all of those INPUT() function calls like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input(b.rule_val_1404,1.)
input(b.rule_val_1304,best9.)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;First don't use BEST as if it meant something special as an INFORMAT.&amp;nbsp; BEST is the name of a FORMAT that tries to find the "best" way to display a number in a fixed number of characters.&amp;nbsp; But there is no similar concept for making a number from a string.&amp;nbsp; There is only one way to store a number in SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then INPUT() function does not care if the WIDTH you use on the INFORMAT specification is larger than the LENGTH of the string being read&amp;nbsp; So unless there are characters past the first byte of&amp;nbsp;rule_val_1404 or the ninth byte of&amp;nbsp;rule_val_1404 you want to ignore then just use width of 32 which is the maximum that the numeric informat supports.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also using short widths on the informats might cause trouble if the character string has leading spaces.&amp;nbsp; What if you had these strings for those two variables?&amp;nbsp; Your INPUT() function calls would return missing value as the result.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;rule_val_1404 = '     1' ;
rule_val_1304 ='          12';
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you are not sure how messy the character variables are you might want to use LEFT() function to remove the leading spaces before converting them into numbers.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input(left(b.rule_val_1404),32.)
input(left(b.rule_val_1304),32.)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Feb 2024 15:53:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Required-operator-not-found-in-expression/m-p/916810#M361119</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-02-19T15:53:49Z</dc:date>
    </item>
  </channel>
</rss>

