<?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: If Statement in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-Statement/m-p/819469#M40916</link>
    <description>&lt;P&gt;I did the below and it brought way more data (I need the second condiiton to meet two conditions (related codes in primary position which is dxseqno=1 AND sufficient codes in secondary or greater position which is dxseqno&amp;gt;1 whereas the first condition is only looking for related codes in primary position only which is dxseqno=1):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dxsuffrel;
set acute_dx;
/*brings in sufficient in primary dx*/
if ((icd in &amp;amp;asthma_suff and dxseqno=1) OR (icd in &amp;amp;cad_suff and dxseqno=1) OR (icd in &amp;amp;chf_suff and dxseqno=1) OR (icd in &amp;amp;copd_suff and dxseqno=1) OR 
(icd in &amp;amp;diab_suff and dxseqno=1) OR (icd in &amp;amp;htn_suff and dxseqno=1)) OR 

/*brings in related in primary dx AND AT LEAST ONE sufficient code in additional dx*/
((icd in &amp;amp;ASTHMA_REL and dxSeqNo = 1) OR (icd in &amp;amp;CAD_REL and dxSeqNo = 1) OR (icd in &amp;amp;CHF_REL and dxSeqNo = 1) OR (icd in &amp;amp;COPD_REL and dxSeqNo = 1) OR 
(icd in &amp;amp;DIAB_REL and dxSeqNo = 1)
OR (icd in &amp;amp;HTN_REL AND dxSeqNo = 1) AND 
(icd in &amp;amp;ASTHMA_SUFF and dxSeqNo&amp;gt;1) OR (icd in &amp;amp;CAD_SUFF and dxSeqNo&amp;gt;1) OR (icd in &amp;amp;CHF_SUFF and dxSeqNo&amp;gt;1) OR (icd in &amp;amp;COPD_SUFF and dxSeqNo&amp;gt;1) OR
(icd in &amp;amp;DIAB_SUFF and dxSeqNo&amp;gt;1) OR
(icd in &amp;amp;HTN_SUFF AND dxSeqNo &amp;gt; 1));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 21 Jun 2022 21:10:52 GMT</pubDate>
    <dc:creator>bhca60</dc:creator>
    <dc:date>2022-06-21T21:10:52Z</dc:date>
    <item>
      <title>If Statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-Statement/m-p/819410#M40904</link>
      <description>&lt;P&gt;I'm trying to bring in two types of data:&lt;/P&gt;
&lt;P&gt;1)&amp;nbsp; &amp;nbsp;only those ids with suff codes in the primary position (dxSeqNo=1) ;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;OR&lt;/P&gt;
&lt;P&gt;2) those with suff codes in the primary position AND those with rel code(s) in the secondary or greater position (dxSeqNo &amp;gt;1).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the below in SAS but it doesnt seem to be bringing it what I'm trying to ask for:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dxsuffrel;
set acute_dx;
/*brings in sufficient in primary dx*/
if ((compress(icd,".") in (&amp;amp;asthma_suff, &amp;amp;cad_suff, &amp;amp;chf_suff, &amp;amp;copd_suff, &amp;amp;diab_suff, &amp;amp;htn_suff) and dxseqno=1)) OR 

/*brings in related in primary dx AND AT LEAST ONE sufficient code in additional dx*/
((compress(icd,".") in (&amp;amp;ASTHMA_REL, &amp;amp;CAD_REL, &amp;amp;CHF_REL, &amp;amp;COPD_REL, &amp;amp;DIAB_REL, &amp;amp;HTN_REL) AND dxSeqNo = 1)) AND 
((compress(icd,".") in (&amp;amp;ASTHMA_SUFF, &amp;amp;CAD_SUFF, &amp;amp;CHF_SUFF, &amp;amp;COPD_SUFF, &amp;amp;DIAB_SUFF, &amp;amp;HTN_SUFF) AND dxSeqNo &amp;gt; 1));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Jun 2022 18:12:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-Statement/m-p/819410#M40904</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2022-06-21T18:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-Statement/m-p/819422#M40906</link>
      <description>&lt;P&gt;We don't know what your code is doing since we can't see (a portion of) your data and we don't have your macro variables; and we don't know what output you are getting that isn't correct.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So we would need ALL of that information in order to be specific.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, one thing you might want to consider is that in your IF statement (which simplified looks like this)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if condition1 or condition2 and condition 3;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is evaluated as&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if condition1 or (condition2 and condition 3);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and not as&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if (condition1 or condition2) and condition 3;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want this last IF statement you need to add proper parentheses.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;And if that's not the problem then we need to see all the information I requested above.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 18:32:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-Statement/m-p/819422#M40906</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-21T18:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-Statement/m-p/819424#M40907</link>
      <description>yes its a parentheses issue. Thats where I'm confused.</description>
      <pubDate>Tue, 21 Jun 2022 18:35:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-Statement/m-p/819424#M40907</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2022-06-21T18:35:17Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-Statement/m-p/819433#M40908</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/290946"&gt;@bhca60&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;yes its a parentheses issue. Thats where I'm confused.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;There's not enough information here for me to understand the problem.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 18:56:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-Statement/m-p/819433#M40908</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-21T18:56:17Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-Statement/m-p/819434#M40909</link>
      <description>I want this to be the outcome:&lt;BR /&gt;if (condition1 or condition2) and condition 3;&lt;BR /&gt;do i have too many parentheses or too little?</description>
      <pubDate>Tue, 21 Jun 2022 18:58:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-Statement/m-p/819434#M40909</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2022-06-21T18:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-Statement/m-p/819435#M40910</link>
      <description>&lt;P&gt;You probably have matching parentheses otherwise you would get an error in the log and no output data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you need to add parentheses such that both parts of the OR condition are enclosed in parentheses.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 19:02:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-Statement/m-p/819435#M40910</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-21T19:02:14Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-Statement/m-p/819451#M40912</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/290946"&gt;@bhca60&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I want this to be the outcome:&lt;BR /&gt;if (condition1 or condition2) and condition 3;&lt;BR /&gt;do i have too many parentheses or too little?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes. Both.&lt;/P&gt;
&lt;P&gt;You are running this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if ((  compress(icd,".") in (&amp;amp;asthma_suff, &amp;amp;cad_suff, &amp;amp;chf_suff, &amp;amp;copd_suff, &amp;amp;diab_suff, &amp;amp;htn_suff)
       and dxseqno=1
   ))
OR 
   ((  compress(icd,".") in (&amp;amp;ASTHMA_REL, &amp;amp;CAD_REL, &amp;amp;CHF_REL, &amp;amp;COPD_REL, &amp;amp;DIAB_REL, &amp;amp;HTN_REL)
       AND dxSeqNo = 1
   ))
AND 
   ((  compress(icd,".") in (&amp;amp;ASTHMA_SUFF, &amp;amp;CAD_SUFF, &amp;amp;CHF_SUFF, &amp;amp;COPD_SUFF, &amp;amp;DIAB_SUFF, &amp;amp;HTN_SUFF)
       AND dxSeqNo &amp;gt; 1
   ))
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So you don't need those doubled parentheses.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you do need to add a set to group the two OR conditions together.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if (
    (  compress(icd,".") in (&amp;amp;asthma_suff, &amp;amp;cad_suff, &amp;amp;chf_suff, &amp;amp;copd_suff, &amp;amp;diab_suff, &amp;amp;htn_suff)
       and dxseqno=1
    )
   OR 
    (  compress(icd,".") in (&amp;amp;ASTHMA_REL, &amp;amp;CAD_REL, &amp;amp;CHF_REL, &amp;amp;COPD_REL, &amp;amp;DIAB_REL, &amp;amp;HTN_REL)
       AND dxSeqNo = 1
    )
   )
AND 
   (  compress(icd,".") in (&amp;amp;ASTHMA_SUFF, &amp;amp;CAD_SUFF, &amp;amp;CHF_SUFF, &amp;amp;COPD_SUFF, &amp;amp;DIAB_SUFF, &amp;amp;HTN_SUFF)
       AND dxSeqNo &amp;gt; 1
   )
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But that first test and the last test cannot both be true since DXSEQNO cannot be both 1 and greater than 1 at the same time.&amp;nbsp;So perhaps you meant to do this instead?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if (  compress(icd,".") in (&amp;amp;ASTHMA_REL, &amp;amp;CAD_REL, &amp;amp;CHF_REL, &amp;amp;COPD_REL, &amp;amp;DIAB_REL, &amp;amp;HTN_REL)
       AND dxSeqNo = 1
   )
OR
   (  compress(icd,".") in (&amp;amp;ASTHMA_SUFF, &amp;amp;CAD_SUFF, &amp;amp;CHF_SUFF, &amp;amp;COPD_SUFF, &amp;amp;DIAB_SUFF, &amp;amp;HTN_SUFF)
       AND dxSeqNo &amp;gt; 1
   )
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 20:07:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-Statement/m-p/819451#M40912</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-06-21T20:07:07Z</dc:date>
    </item>
    <item>
      <title>Re: If Statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-Statement/m-p/819469#M40916</link>
      <description>&lt;P&gt;I did the below and it brought way more data (I need the second condiiton to meet two conditions (related codes in primary position which is dxseqno=1 AND sufficient codes in secondary or greater position which is dxseqno&amp;gt;1 whereas the first condition is only looking for related codes in primary position only which is dxseqno=1):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dxsuffrel;
set acute_dx;
/*brings in sufficient in primary dx*/
if ((icd in &amp;amp;asthma_suff and dxseqno=1) OR (icd in &amp;amp;cad_suff and dxseqno=1) OR (icd in &amp;amp;chf_suff and dxseqno=1) OR (icd in &amp;amp;copd_suff and dxseqno=1) OR 
(icd in &amp;amp;diab_suff and dxseqno=1) OR (icd in &amp;amp;htn_suff and dxseqno=1)) OR 

/*brings in related in primary dx AND AT LEAST ONE sufficient code in additional dx*/
((icd in &amp;amp;ASTHMA_REL and dxSeqNo = 1) OR (icd in &amp;amp;CAD_REL and dxSeqNo = 1) OR (icd in &amp;amp;CHF_REL and dxSeqNo = 1) OR (icd in &amp;amp;COPD_REL and dxSeqNo = 1) OR 
(icd in &amp;amp;DIAB_REL and dxSeqNo = 1)
OR (icd in &amp;amp;HTN_REL AND dxSeqNo = 1) AND 
(icd in &amp;amp;ASTHMA_SUFF and dxSeqNo&amp;gt;1) OR (icd in &amp;amp;CAD_SUFF and dxSeqNo&amp;gt;1) OR (icd in &amp;amp;CHF_SUFF and dxSeqNo&amp;gt;1) OR (icd in &amp;amp;COPD_SUFF and dxSeqNo&amp;gt;1) OR
(icd in &amp;amp;DIAB_SUFF and dxSeqNo&amp;gt;1) OR
(icd in &amp;amp;HTN_SUFF AND dxSeqNo &amp;gt; 1));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Jun 2022 21:10:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-Statement/m-p/819469#M40916</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2022-06-21T21:10:52Z</dc:date>
    </item>
  </channel>
</rss>

