<?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: Conditional logic in proc means? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Conditional-logic-in-proc-means/m-p/388318#M93118</link>
    <description>&lt;P&gt;You should change your data, so that the 999 don't mean "missing".&amp;nbsp; For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;if age=999 then age=.U;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you can use a simple PROC MEANS:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc means data=want;&lt;/P&gt;
&lt;P&gt;var income age;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By using a special missing value (.U), you can easily differentiate which values used to be 999, vs. which are missing for some other reason.&amp;nbsp; And PROC MEANS knows enough to omit any type of missing value from the calculations.&lt;/P&gt;</description>
    <pubDate>Tue, 15 Aug 2017 21:17:59 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-08-15T21:17:59Z</dc:date>
    <item>
      <title>Conditional logic in proc means?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-logic-in-proc-means/m-p/388309#M93116</link>
      <description>&lt;P&gt;/*Hi SAS Forum,&lt;/P&gt;&lt;P&gt;I have posted this same question in another forum and am repeating here too due to urgency of resutls generation.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I am having below dataset.&lt;BR /&gt;For variable "income", value 999 means the income of the person is actually $999.&lt;BR /&gt;However, for "Age" varaible, the value 999 means the value is unknown or missing. */&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Data have;&lt;BR /&gt;input income Age;&lt;BR /&gt;cards;&lt;BR /&gt;100 999&lt;BR /&gt;200 25&lt;BR /&gt;999 30&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;/*Q: I want to calcualte min, max and mean of these 2 vairables using proc means.&lt;BR /&gt;We cannot use other methods but must use proc means for calculating min, max and mean (otherwise&lt;BR /&gt;it upsets our original long SAS code).&lt;BR /&gt;&lt;BR /&gt;Answer:&lt;BR /&gt;&lt;BR /&gt;for income, min=100&amp;nbsp; max=999&amp;nbsp; mean=433&lt;BR /&gt;for Age min=25&amp;nbsp; max=30&amp;nbsp; mean=27.5&amp;nbsp; (because value 999 should be omitted from Age variable)&lt;BR /&gt;&lt;BR /&gt;I attmepted below code, but getting me no where. Could an expert help me.&lt;BR /&gt;Thanks, Mirisa*/&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;%macro any (field);&lt;BR /&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;&lt;BR /&gt;%if &amp;amp;field ="income" %then %do;&lt;BR /&gt;proc means data=have;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;var &amp;amp;field;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;&lt;BR /&gt;%mend any;&lt;BR /&gt;%any (income);&lt;BR /&gt;%any (Age);&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2017 21:07:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-logic-in-proc-means/m-p/388309#M93116</guid>
      <dc:creator>dunga</dc:creator>
      <dc:date>2017-08-15T21:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional logic in proc means?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-logic-in-proc-means/m-p/388318#M93118</link>
      <description>&lt;P&gt;You should change your data, so that the 999 don't mean "missing".&amp;nbsp; For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;if age=999 then age=.U;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you can use a simple PROC MEANS:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc means data=want;&lt;/P&gt;
&lt;P&gt;var income age;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By using a special missing value (.U), you can easily differentiate which values used to be 999, vs. which are missing for some other reason.&amp;nbsp; And PROC MEANS knows enough to omit any type of missing value from the calculations.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2017 21:17:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-logic-in-proc-means/m-p/388318#M93118</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-08-15T21:17:59Z</dc:date>
    </item>
  </channel>
</rss>

