<?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 else in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/If-then-else/m-p/421238#M67953</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am having a trouble with my if then else statements,&lt;/P&gt;&lt;P&gt;I wrote&lt;/P&gt;&lt;P&gt;data all_1;&lt;BR /&gt;set total;&lt;BR /&gt;if hud080=. then h_count=.;&lt;BR /&gt;else if hud080=77777 then h_count= .;&lt;BR /&gt;else if hud080=99999 then h_count=.;&lt;BR /&gt;else if huq071=1 and hud080=1 then h_count=1;&lt;BR /&gt;else if huq071=1 and hud080 in (2,3,4,5,6) then h_count=2;&lt;/P&gt;&lt;P&gt;else if huq071=2 then h_count=0;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then my output for proc freq does not have h_count=0. Could anyone explain why h_count=0 is missing ?&amp;nbsp; Thanks&lt;/P&gt;&lt;P&gt;SAS Output&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;h_count&amp;nbsp;Frequency Percent CumulativeFrequency CumulativePercent12Frequency Missing = 45980&amp;nbsp; &lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;3705&lt;/TD&gt;&lt;TD&gt;74.32&lt;/TD&gt;&lt;TD&gt;3705&lt;/TD&gt;&lt;TD&gt;74.32&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1280&lt;/TD&gt;&lt;TD&gt;25.68&lt;/TD&gt;&lt;TD&gt;4985&lt;/TD&gt;&lt;TD&gt;100.00&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Thu, 14 Dec 2017 16:25:30 GMT</pubDate>
    <dc:creator>leahcho</dc:creator>
    <dc:date>2017-12-14T16:25:30Z</dc:date>
    <item>
      <title>If then else</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/If-then-else/m-p/421238#M67953</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am having a trouble with my if then else statements,&lt;/P&gt;&lt;P&gt;I wrote&lt;/P&gt;&lt;P&gt;data all_1;&lt;BR /&gt;set total;&lt;BR /&gt;if hud080=. then h_count=.;&lt;BR /&gt;else if hud080=77777 then h_count= .;&lt;BR /&gt;else if hud080=99999 then h_count=.;&lt;BR /&gt;else if huq071=1 and hud080=1 then h_count=1;&lt;BR /&gt;else if huq071=1 and hud080 in (2,3,4,5,6) then h_count=2;&lt;/P&gt;&lt;P&gt;else if huq071=2 then h_count=0;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then my output for proc freq does not have h_count=0. Could anyone explain why h_count=0 is missing ?&amp;nbsp; Thanks&lt;/P&gt;&lt;P&gt;SAS Output&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;h_count&amp;nbsp;Frequency Percent CumulativeFrequency CumulativePercent12Frequency Missing = 45980&amp;nbsp; &lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;3705&lt;/TD&gt;&lt;TD&gt;74.32&lt;/TD&gt;&lt;TD&gt;3705&lt;/TD&gt;&lt;TD&gt;74.32&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1280&lt;/TD&gt;&lt;TD&gt;25.68&lt;/TD&gt;&lt;TD&gt;4985&lt;/TD&gt;&lt;TD&gt;100.00&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 14 Dec 2017 16:25:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/If-then-else/m-p/421238#M67953</guid>
      <dc:creator>leahcho</dc:creator>
      <dc:date>2017-12-14T16:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: If then else</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/If-then-else/m-p/421240#M67954</link>
      <description>&lt;P&gt;No, we can't tell you why that is, you have not shown any test data.&amp;nbsp; SAS is based on data, without that part the logic doesn't do anything.&amp;nbsp; At a guess:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;else if huq071=2 then h_count=0;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This condition is never met.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Maybe you meant:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;else h_count=0;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2017 16:31:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/If-then-else/m-p/421240#M67954</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-12-14T16:31:39Z</dc:date>
    </item>
    <item>
      <title>Re: If then else</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/If-then-else/m-p/421242#M67955</link>
      <description>&lt;P&gt;The IF/THEN statements look OK.&amp;nbsp; Maybe the problem is with the data.&amp;nbsp; Do you actually have any observations that have 2 as the value of HUQ071?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a good way to check what is in your data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc format;&lt;/P&gt;
&lt;P&gt;value check .='Missing'&amp;nbsp;&amp;nbsp; 77777 = '77777'&amp;nbsp; 99999='99999'&amp;nbsp;&amp;nbsp; other='Valid';&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=have;&lt;/P&gt;
&lt;P&gt;tables HUQ071 * HUD080 / missing;&lt;/P&gt;
&lt;P&gt;format HUD080 check. ;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2017 16:36:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/If-then-else/m-p/421242#M67955</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-12-14T16:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: If then else</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/If-then-else/m-p/421266#M67956</link>
      <description>&lt;P&gt;If you have many values for each of the two variables this modification of &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;'s Proc freq may be of interest:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=have;&lt;/P&gt;
&lt;P&gt;tables HUQ071 * HUD080 / list nopercent&amp;nbsp;missing;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The LIST option creates one row per combination instead of the large two dimensional table and suppresses all of the percentages which I seldom find helpful in identifying data combinations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2017 17:43:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/If-then-else/m-p/421266#M67956</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-12-14T17:43:14Z</dc:date>
    </item>
  </channel>
</rss>

