<?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 if/then problem creating a variable in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/if-then-problem-creating-a-variable/m-p/751026#M10051</link>
    <description>&lt;P&gt;I'm using ODA, trying to create a variable with this code -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;libname adeno '/home/u58566978/adeno';&lt;BR /&gt;data work.adeno1;&lt;BR /&gt;set adeno.finch_gjred;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data work.adeno1;&lt;BR /&gt;set adeno.finch_gjred;&lt;BR /&gt;if beertotl=2 and beerfrq2=0 and beerfrqx2=0 and beernum2=98 then wrong=0;&lt;BR /&gt;if beertotl=3 and beerfrq3=0 and beerfrqx3=0 and beernum3=98 then wrong=0;&lt;BR /&gt;if beertotl=4 and beerfrq4=0 and beerfrqx4=0 and beernum4=98 then wrong=0;&lt;BR /&gt;if beertotl=5 and beerfrq5=0 and beerfrqx5=0 and beernum5=98 then wrong=0;&lt;BR /&gt;if beertotl=6 and beerfrq6=0 and beerfrqx6=0 and beernum6=98 then wrong=0;&lt;BR /&gt;if beertotl=7 and beerfrq7=0 and beerfrqx7=0 and beernum7=98 then wrong=0;&lt;BR /&gt;if beertotl=8 and beerfrq8=0 and beerfrqx8=0 and beernum8=98 then wrong=0;&lt;BR /&gt;if beertotl=9 and beerfrq9=0 and beerfrqx9=0 and beernum9=98 then wrong=0;&lt;BR /&gt;if beertotl=10 and beerfrq10=0 and beerfrqx10=0 and beernum10=98 then wrong=0;&lt;BR /&gt;if beertotl=11 and beerfrq11=0 and beerfrqx11=0 and beernum11=98 then wrong=0;&lt;BR /&gt;if beertotl=12 and beerfrq12=0 and beerfrqx12=0 and beernum12=98 then wrong=0;&lt;BR /&gt;else wrong=1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc freq data=work.adeno1;&lt;BR /&gt;tables wrong;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;....but when I do that, this is the table I get.&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2021-06-29 at 1.56.49 PM.png" style="width: 952px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/60815iF29BDFD9028EB725/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2021-06-29 at 1.56.49 PM.png" alt="Screen Shot 2021-06-29 at 1.56.49 PM.png" /&gt;&lt;/span&gt;When I exclude the 'else wrong=1' line, I get this, which is what I want, but I need to have a "1=832" line instead of those people being considered missing. Is this an ordering problem in my code? Any help is much appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2021-06-29 at 1.58.43 PM.png" style="width: 822px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/60816iE6CC1FF5941B5F15/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2021-06-29 at 1.58.43 PM.png" alt="Screen Shot 2021-06-29 at 1.58.43 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Jun 2021 18:00:41 GMT</pubDate>
    <dc:creator>gejoachim99</dc:creator>
    <dc:date>2021-06-29T18:00:41Z</dc:date>
    <item>
      <title>if/then problem creating a variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/if-then-problem-creating-a-variable/m-p/751026#M10051</link>
      <description>&lt;P&gt;I'm using ODA, trying to create a variable with this code -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;libname adeno '/home/u58566978/adeno';&lt;BR /&gt;data work.adeno1;&lt;BR /&gt;set adeno.finch_gjred;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data work.adeno1;&lt;BR /&gt;set adeno.finch_gjred;&lt;BR /&gt;if beertotl=2 and beerfrq2=0 and beerfrqx2=0 and beernum2=98 then wrong=0;&lt;BR /&gt;if beertotl=3 and beerfrq3=0 and beerfrqx3=0 and beernum3=98 then wrong=0;&lt;BR /&gt;if beertotl=4 and beerfrq4=0 and beerfrqx4=0 and beernum4=98 then wrong=0;&lt;BR /&gt;if beertotl=5 and beerfrq5=0 and beerfrqx5=0 and beernum5=98 then wrong=0;&lt;BR /&gt;if beertotl=6 and beerfrq6=0 and beerfrqx6=0 and beernum6=98 then wrong=0;&lt;BR /&gt;if beertotl=7 and beerfrq7=0 and beerfrqx7=0 and beernum7=98 then wrong=0;&lt;BR /&gt;if beertotl=8 and beerfrq8=0 and beerfrqx8=0 and beernum8=98 then wrong=0;&lt;BR /&gt;if beertotl=9 and beerfrq9=0 and beerfrqx9=0 and beernum9=98 then wrong=0;&lt;BR /&gt;if beertotl=10 and beerfrq10=0 and beerfrqx10=0 and beernum10=98 then wrong=0;&lt;BR /&gt;if beertotl=11 and beerfrq11=0 and beerfrqx11=0 and beernum11=98 then wrong=0;&lt;BR /&gt;if beertotl=12 and beerfrq12=0 and beerfrqx12=0 and beernum12=98 then wrong=0;&lt;BR /&gt;else wrong=1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc freq data=work.adeno1;&lt;BR /&gt;tables wrong;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;....but when I do that, this is the table I get.&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2021-06-29 at 1.56.49 PM.png" style="width: 952px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/60815iF29BDFD9028EB725/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2021-06-29 at 1.56.49 PM.png" alt="Screen Shot 2021-06-29 at 1.56.49 PM.png" /&gt;&lt;/span&gt;When I exclude the 'else wrong=1' line, I get this, which is what I want, but I need to have a "1=832" line instead of those people being considered missing. Is this an ordering problem in my code? Any help is much appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2021-06-29 at 1.58.43 PM.png" style="width: 822px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/60816iE6CC1FF5941B5F15/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2021-06-29 at 1.58.43 PM.png" alt="Screen Shot 2021-06-29 at 1.58.43 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jun 2021 18:00:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/if-then-problem-creating-a-variable/m-p/751026#M10051</guid>
      <dc:creator>gejoachim99</dc:creator>
      <dc:date>2021-06-29T18:00:41Z</dc:date>
    </item>
    <item>
      <title>Re: if/then problem creating a variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/if-then-problem-creating-a-variable/m-p/751027#M10052</link>
      <description>&lt;P&gt;Your ELSE is not correct. Try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname adeno '/home/u58566978/adeno';
/*These next three lines not relevant to this problem, so I have commented them out */
/*data work.adeno1;*/
/*set adeno.finch_gjred;*/
/*run;*/

data work.adeno1;
    set adeno.finch_gjred;
    if beertotl=2 and beerfrq2=0 and beerfrqx2=0 and beernum2=98 then wrong=0;
    else if beertotl=3 and beerfrq3=0 and beerfrqx3=0 and beernum3=98 then wrong=0;
    else if beertotl=4 and beerfrq4=0 and beerfrqx4=0 and beernum4=98 then wrong=0;
    else if beertotl=5 and beerfrq5=0 and beerfrqx5=0 and beernum5=98 then wrong=0;
    else if beertotl=6 and beerfrq6=0 and beerfrqx6=0 and beernum6=98 then wrong=0;
    else if beertotl=7 and beerfrq7=0 and beerfrqx7=0 and beernum7=98 then wrong=0;
    else if beertotl=8 and beerfrq8=0 and beerfrqx8=0 and beernum8=98 then wrong=0;
    else if beertotl=9 and beerfrq9=0 and beerfrqx9=0 and beernum9=98 then wrong=0;
    else if beertotl=10 and beerfrq10=0 and beerfrqx10=0 and beernum10=98 then wrong=0;
    else if beertotl=11 and beerfrq11=0 and beerfrqx11=0 and beernum11=98 then wrong=0;
    else if beertotl=12 and beerfrq12=0 and beerfrqx12=0 and beernum12=98 then wrong=0;
    else wrong=1;
run;

proc freq data=work.adeno1;
    tables wrong;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You might also benefit from properly indenting your code, as I have done above.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jun 2021 18:12:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/if-then-problem-creating-a-variable/m-p/751027#M10052</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-06-29T18:12:42Z</dc:date>
    </item>
  </channel>
</rss>

