<?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 Expecting an arithmetic operator in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Expecting-an-arithmetic-operator/m-p/384383#M91885</link>
    <description>&lt;P&gt;I have the following code. I basically want to filter a table so that you are left with only the information relevant for the car colors in the table want_options. In dataset have_options, the car colors are listed in 3 different rows in column_a (i.e. blue on top of red on top of white). In the first data step, i have created want_options which combines these 3 rows into 1 row in column_b (new column), so it now appears as "blue", "red", "white" in 1 cell next to eachother. In the last data step, I want to filter dataset have_data by the selected colors from want_options (in this case blue, red, and white were chosen).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when I run the last data step, it highlights the comma in the line "blue", "red", "white" from the macro variable &amp;amp;car_color_options. and says both:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR 388-185: Expecting an arithmetic operator.&lt;/P&gt;&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Data want_options;
  Set have_options;&lt;BR /&gt;     By car_brand;
  If first.car_brand then column_b = cats('"', column_a, '"');
  Else column_b = (column_b, ' ,', '"', column_a, '"');
  /* '"" is basically '  "  ' in case you can't tell */
Run;

%Let car_color = "";

Data _null_;
  Set want_options;
  If car_brand = "car_color" then call symput('car_color_options', column_b);
Run;

Data outcome;
  Set have_data;
  If &amp;amp;car_color_options. = "" then car_color_selected = 1;
  Else &amp;amp;car_color_options. ^= "" and car_color in (&amp;amp;car_color_options.) then car_color_selected = 1;
  Else &amp;amp;car_color_options. ^= "" and car_color not in (&amp;amp;car_color_options.) then car_color_selected = 0;
  &lt;BR /&gt;  If car_color_selected = 1 then output;
Run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Anyone know how I can solve this? Thanks&lt;/P&gt;</description>
    <pubDate>Mon, 31 Jul 2017 19:16:34 GMT</pubDate>
    <dc:creator>jos283</dc:creator>
    <dc:date>2017-07-31T19:16:34Z</dc:date>
    <item>
      <title>Expecting an arithmetic operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expecting-an-arithmetic-operator/m-p/384383#M91885</link>
      <description>&lt;P&gt;I have the following code. I basically want to filter a table so that you are left with only the information relevant for the car colors in the table want_options. In dataset have_options, the car colors are listed in 3 different rows in column_a (i.e. blue on top of red on top of white). In the first data step, i have created want_options which combines these 3 rows into 1 row in column_b (new column), so it now appears as "blue", "red", "white" in 1 cell next to eachother. In the last data step, I want to filter dataset have_data by the selected colors from want_options (in this case blue, red, and white were chosen).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when I run the last data step, it highlights the comma in the line "blue", "red", "white" from the macro variable &amp;amp;car_color_options. and says both:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR 388-185: Expecting an arithmetic operator.&lt;/P&gt;&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Data want_options;
  Set have_options;&lt;BR /&gt;     By car_brand;
  If first.car_brand then column_b = cats('"', column_a, '"');
  Else column_b = (column_b, ' ,', '"', column_a, '"');
  /* '"" is basically '  "  ' in case you can't tell */
Run;

%Let car_color = "";

Data _null_;
  Set want_options;
  If car_brand = "car_color" then call symput('car_color_options', column_b);
Run;

Data outcome;
  Set have_data;
  If &amp;amp;car_color_options. = "" then car_color_selected = 1;
  Else &amp;amp;car_color_options. ^= "" and car_color in (&amp;amp;car_color_options.) then car_color_selected = 1;
  Else &amp;amp;car_color_options. ^= "" and car_color not in (&amp;amp;car_color_options.) then car_color_selected = 0;
  &lt;BR /&gt;  If car_color_selected = 1 then output;
Run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Anyone know how I can solve this? Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 19:16:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expecting-an-arithmetic-operator/m-p/384383#M91885</guid>
      <dc:creator>jos283</dc:creator>
      <dc:date>2017-07-31T19:16:34Z</dc:date>
    </item>
    <item>
      <title>Re: Expecting an arithmetic operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expecting-an-arithmetic-operator/m-p/384389#M91886</link>
      <description>&lt;P&gt;Well, you are missing a semi-colon ... and you probably have to put &amp;amp;car_color_options inside %quote(); but&amp;nbsp;if that's not it, you have to show us the SASLOG so we can see WHERE these errors are occurring. Really, in this case showing us a SASLOG ought to be mandatory, we shouldn't have to ask to see where the error is.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 19:00:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expecting-an-arithmetic-operator/m-p/384389#M91886</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-07-31T19:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: Expecting an arithmetic operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expecting-an-arithmetic-operator/m-p/384391#M91887</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps you want the code below? &amp;nbsp;Comparing a list of strings to another string using = or ^= is not valid syntax.&lt;/P&gt;
&lt;PRE&gt;Data outcome;&lt;BR /&gt; Set have_data;&lt;BR /&gt; If symget('car_color_options') = "" then car_color_selected = 1;&lt;BR /&gt; Else symget('car_color_options') ^= "" and car_color in (&amp;amp;car_color_options.) then car_color_selected = 1;&lt;BR /&gt; Else symget('car_color_options') ^= "" and car_color not in (&amp;amp;car_color_options.) then car_color_selected = 0;&lt;BR /&gt; &lt;BR /&gt; If car_color_selected = 1 then output;&lt;BR /&gt;Run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 19:01:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expecting-an-arithmetic-operator/m-p/384391#M91887</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2017-07-31T19:01:47Z</dc:date>
    </item>
    <item>
      <title>Re: Expecting an arithmetic operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expecting-an-arithmetic-operator/m-p/384394#M91888</link>
      <description>&lt;P&gt;This seems like an easy problem for SQL, without needing any macro language:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table want as select have_data.* where have_data.car_color in&lt;/P&gt;
&lt;P&gt;(select distinct column_a from have_options);&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My SQL isn't the strongest, so this may need a little tweaking.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 19:04:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expecting-an-arithmetic-operator/m-p/384394#M91888</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-31T19:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: Expecting an arithmetic operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expecting-an-arithmetic-operator/m-p/384398#M91889</link>
      <description>&lt;P&gt;Please post data exists in &lt;STRONG&gt;have.options,&lt;/STRONG&gt;&amp;nbsp;some test data of &lt;STRONG&gt;have.data&lt;/STRONG&gt; &amp;nbsp;and the full log of your run.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your first step you have:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;If first.column_a then ...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; you cannot use &lt;STRONG&gt;first.column_a&lt;/STRONG&gt; without defining: &lt;STRONG&gt;by colomn_a&lt;/STRONG&gt; &amp;nbsp;and dataset sorted by it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is not enough to post the errors, you have to post the full log in order to see the connection between the code and the error.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 19:14:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expecting-an-arithmetic-operator/m-p/384398#M91889</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-07-31T19:14:44Z</dc:date>
    </item>
    <item>
      <title>Re: Expecting an arithmetic operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expecting-an-arithmetic-operator/m-p/384414#M91890</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Run next code and check carefully the outputs:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%Let car_color = "";

Data want_options;
  Set have_options;
     By car_brand;
         length column_b $30;
         retain column_b;

         If first.car_brand then column_b = cats('"', column_a, '"');
         Else column_b = cats(column_b, ' ,', '"', column_a, '"');
  
         if last.car_brand then output;
		 keep car_brand column_b;
Run;

data temp;
merge have_data 
      want_options; 
  by car_brand;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now you have color options per car_barnd. Which of them should be in a macro variable ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check carefully your logic and post full log of your run.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 19:56:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expecting-an-arithmetic-operator/m-p/384414#M91890</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-07-31T19:56:55Z</dc:date>
    </item>
  </channel>
</rss>

