<?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 and then statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/if-and-then-statement/m-p/876287#M346221</link>
    <description>&lt;P&gt;Your question is deficient. It doesn't say what the desired output is if there are no missings. (It does say what should happen if there are missings)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS is the best "person" to review the code. Run it on sample data and see if it gives the expected output.&lt;/P&gt;</description>
    <pubDate>Wed, 17 May 2023 17:20:11 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-05-17T17:20:11Z</dc:date>
    <item>
      <title>if and then statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-and-then-statement/m-p/876279#M346216</link>
      <description>&lt;P&gt;Can anyone help me review this code? I'm trying to create a composite variable (abuse) but also to create a situation where any missing value across the 5 variables&amp;nbsp;is coded as missing in the new composite variable.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;if ace_swear =1 or ace_hurt=1 or ace_touch=1 or ace_tthem=1 or ace_sex=1 
then abuse=1;
if ace_swear =. and ace_hurt=. and ace_touch=. and ace_tthem=. and ace_sex=. 
then abuse=.;
else abuse=0;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2023 16:54:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-and-then-statement/m-p/876279#M346216</guid>
      <dc:creator>ChuksManuel</dc:creator>
      <dc:date>2023-05-17T16:54:04Z</dc:date>
    </item>
    <item>
      <title>Re: if and then statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-and-then-statement/m-p/876287#M346221</link>
      <description>&lt;P&gt;Your question is deficient. It doesn't say what the desired output is if there are no missings. (It does say what should happen if there are missings)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS is the best "person" to review the code. Run it on sample data and see if it gives the expected output.&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2023 17:20:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-and-then-statement/m-p/876287#M346221</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-17T17:20:11Z</dc:date>
    </item>
    <item>
      <title>Re: if and then statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-and-then-statement/m-p/876292#M346223</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's not giving me any error. It's however not giving me what i want. I want the new variable created "abuse" to have 0,1 and missing. With "abuse" called to missing if an observation has missing in all the 5 composite variables. I will appreciate if you can refer me to materials to help me figure this out. I know i'm just missing a small piece of code.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ChuksManuel_0-1684344580245.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84064i8362061D672EB1F2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ChuksManuel_0-1684344580245.png" alt="ChuksManuel_0-1684344580245.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2023 17:30:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-and-then-statement/m-p/876292#M346223</guid>
      <dc:creator>ChuksManuel</dc:creator>
      <dc:date>2023-05-17T17:30:40Z</dc:date>
    </item>
    <item>
      <title>Re: if and then statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-and-then-statement/m-p/876293#M346224</link>
      <description>&lt;P&gt;You missed an else.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;if ace_swear =1 or ace_hurt=1 or ace_touch=1 or ace_tthem=1 or ace_sex=1 
then abuse=1;
&lt;FONT size="4" color="#FF0000"&gt;ELSE&lt;/FONT&gt; if ace_swear =. and ace_hurt=. and ace_touch=. and ace_tthem=. and ace_sex=. 
then abuse=.;
else abuse=0;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 May 2023 17:36:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-and-then-statement/m-p/876293#M346224</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-05-17T17:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: if and then statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-and-then-statement/m-p/876294#M346225</link>
      <description>Thanks!</description>
      <pubDate>Wed, 17 May 2023 17:39:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-and-then-statement/m-p/876294#M346225</guid>
      <dc:creator>ChuksManuel</dc:creator>
      <dc:date>2023-05-17T17:39:50Z</dc:date>
    </item>
    <item>
      <title>Re: if and then statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-and-then-statement/m-p/876295#M346226</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/236266"&gt;@ChuksManuel&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's not giving me any error. It's however not giving me what i want. I want the new variable created "abuse" to have 0,1 and missing. With "abuse" called to missing if an observation has missing in all the 5 composite variables. I will appreciate if you can refer me to materials to help me figure this out. I know i'm just missing a small piece of code.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ChuksManuel_0-1684344580245.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84064i8362061D672EB1F2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ChuksManuel_0-1684344580245.png" alt="ChuksManuel_0-1684344580245.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Sounds like you don't need IF/THEN at all.&amp;nbsp; Just use MAX() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;abuse = max( of ace_swear ace_hurt ace_touch ace_tthem ace_sex);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's test the idea by making some data that covers all possible combinations of two variables with 0,1 or . as possible values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
do x=.,0,1; do y=.,0,1; 
  want=max(of x y);
  output;
end; end; 
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;PRE&gt;Obs    x    y    want

 1     .    .      .
 2     .    0      0
 3     .    1      1
 4     0    .      0
 5     0    0      0
 6     0    1      1
 7     1    .      1
 8     1    0      1
 9     1    1      1
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2023 17:59:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-and-then-statement/m-p/876295#M346226</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-05-17T17:59:51Z</dc:date>
    </item>
  </channel>
</rss>

