<?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: how to create a flag variable with multiple conditions in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-flag-variable-with-multiple-conditions/m-p/729159#M226886</link>
    <description>&lt;P&gt;Please explain what is not working.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is an error in the log, please show us the log of this PROC SQL, all of it, not selected parts. To show us the log, please format it properly so that it is readable by copying the log as text and pasting it into the window that appears when you click on the &amp;lt;/&amp;gt; icon.&amp;nbsp;&lt;STRONG&gt;DO NOT SKIP THIS STEP&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the problem is that it gives the wrong output, please explain in detail.&lt;/P&gt;</description>
    <pubDate>Thu, 25 Mar 2021 18:19:27 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-03-25T18:19:27Z</dc:date>
    <item>
      <title>how to create a flag variable with multiple conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-flag-variable-with-multiple-conditions/m-p/729152#M226881</link>
      <description>&lt;P&gt;I'm trying to create a flag variable for respondents that answered S3 = 1 and Q11 ne 1 and if either timer variables had &amp;lt;1&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried the following syntax, which doesn't seem to be working.&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;proc SQL;
create table flagstemcell as
select S3, Q11, treatment_feature_Timer, treatment_benefit_Timer, treatment_benefit_2_Timer, complete_response_information_Ti, treatment_side_effects_1_Timer
	treatment_side_effects_2_Timer, treatment_side_effects_3_Timer, treatment_risk_Timer 
	When S3 = 1 and Q11 NE 1 and treatment_feature_Timer &amp;lt;10 or treatment_benefit_Timer &amp;lt;10 or treatment_benefit_2_Timer &amp;lt;10 
	or complete_response_information_Ti &amp;lt;10 or treatment_side_effects_1_Timer &amp;lt; 10 	treatment_side_effects_2_Timer &amp;lt;10 or treatment_side_effects_3_Timer or treatment_risk_Timer 
from MM1;
group by record;
quit; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Mar 2021 18:03:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-flag-variable-with-multiple-conditions/m-p/729152#M226881</guid>
      <dc:creator>kgrover</dc:creator>
      <dc:date>2021-03-25T18:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a flag variable with multiple conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-flag-variable-with-multiple-conditions/m-p/729159#M226886</link>
      <description>&lt;P&gt;Please explain what is not working.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is an error in the log, please show us the log of this PROC SQL, all of it, not selected parts. To show us the log, please format it properly so that it is readable by copying the log as text and pasting it into the window that appears when you click on the &amp;lt;/&amp;gt; icon.&amp;nbsp;&lt;STRONG&gt;DO NOT SKIP THIS STEP&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the problem is that it gives the wrong output, please explain in detail.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Mar 2021 18:19:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-flag-variable-with-multiple-conditions/m-p/729159#M226886</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-03-25T18:19:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a flag variable with multiple conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-flag-variable-with-multiple-conditions/m-p/729160#M226887</link>
      <description>&lt;P&gt;Please include your log when you have errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Issues:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Semicolons that end your query early&lt;/LI&gt;
&lt;LI&gt;Clauses out of order (SELECT/FROM/WHERE/GROUP/ORDER) is a rough order, in the query posted WHERE is before FROM&lt;/LI&gt;
&lt;LI&gt;Missing brackets for the OR statements&lt;/LI&gt;
&lt;LI&gt;Missing OR or comparisons for some of the timer variables.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;I've cleaned it up somewhat but you may still have logical and syntax issues here. If so, and you cannot debug it based on the log make sure you post both the code and log in future responses.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc SQL;
create table flagstemcell as
select S3, Q11, treatment_feature_Timer, treatment_benefit_Timer, treatment_benefit_2_Timer, complete_response_information_Ti, treatment_side_effects_1_Timer
	treatment_side_effects_2_Timer, treatment_side_effects_3_Timer, treatment_risk_Timer 
	
from MM1

When S3 = 1 and Q11 NE 1 and (treatment_feature_Timer &amp;lt;10 or treatment_benefit_Timer &amp;lt;10 or treatment_benefit_2_Timer &amp;lt;10 
	or complete_response_information_Ti &amp;lt;10 or treatment_side_effects_1_Timer &amp;lt; 10 or	treatment_side_effects_2_Timer &amp;lt;10 or treatment_side_effects_3_Timer&amp;lt;10 or treatment_risk_Timer &amp;lt;10

group by record;
quit; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/101951"&gt;@kgrover&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm trying to create a flag variable for respondents that answered S3 = 1 and Q11 ne 1 and if either timer variables had &amp;lt;1&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tried the following syntax, which doesn't seem to be working.&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;proc SQL;
create table flagstemcell as
select S3, Q11, treatment_feature_Timer, treatment_benefit_Timer, treatment_benefit_2_Timer, complete_response_information_Ti, treatment_side_effects_1_Timer
	treatment_side_effects_2_Timer, treatment_side_effects_3_Timer, treatment_risk_Timer 
	When S3 = 1 and Q11 NE 1 and treatment_feature_Timer &amp;lt;10 or treatment_benefit_Timer &amp;lt;10 or treatment_benefit_2_Timer &amp;lt;10 
	or complete_response_information_Ti &amp;lt;10 or treatment_side_effects_1_Timer &amp;lt; 10 	treatment_side_effects_2_Timer &amp;lt;10 or treatment_side_effects_3_Timer or treatment_risk_Timer 
from MM1;
group by record;
quit; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Mar 2021 18:20:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-flag-variable-with-multiple-conditions/m-p/729160#M226887</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-03-25T18:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a flag variable with multiple conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-flag-variable-with-multiple-conditions/m-p/729164#M226888</link>
      <description>&lt;P&gt;First format your code neatly so you can more easily see and fix the obvious typos and syntax errors.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc SQL;
create table flagstemcell as
select
    S3
  , Q11
  , treatment_feature_Timer
  , treatment_benefit_Timer
  , treatment_benefit_2_Timer
  , complete_response_information_Ti
  , treatment_side_effects_1_Timer
  	treatment_side_effects_2_Timer
  , treatment_side_effects_3_Timer
  , treatment_risk_Timer 
  	When S3 = 1
     and Q11 NE 1
     and treatment_feature_Timer &amp;lt;10
      or treatment_benefit_Timer &amp;lt;10
      or treatment_benefit_2_Timer &amp;lt;10 
  	  or complete_response_information_Ti &amp;lt;10
      or treatment_side_effects_1_Timer &amp;lt; 10 	
         treatment_side_effects_2_Timer &amp;lt;10 
      or treatment_side_effects_3_Timer 
      or treatment_risk_Timer 
  from MM1
;
  group by record
;
quit; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then add grouping () to your conditions so they make sense.&amp;nbsp; If you code&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;A and B or C or D&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What are you asking for?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you asking for&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;(A and B) or C or D&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;A and (B or C or D)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;?&lt;/P&gt;</description>
      <pubDate>Thu, 25 Mar 2021 18:30:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-flag-variable-with-multiple-conditions/m-p/729164#M226888</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-03-25T18:30:24Z</dc:date>
    </item>
  </channel>
</rss>

