<?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: Proc sql Language in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-Language/m-p/378587#M91018</link>
    <description>&lt;P&gt;Firstly e and d are aliases i.e. they are ways of referring to different variables in different data sets. In this particular case e and d both refer to the same data set and what is being produced is a cartesian product i.e. a data set which contains all possible combinations of weights (the table is being joined with itself).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The highlighted code is basically a complicated way of finding the median (i.e. the value with the same number of observations which are greater than it and which are less than it) by using the sum of differences. If you're using SAS 9.4 you can simply do this instead&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	select median(weight)
	from class;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 24 Jul 2017 07:10:54 GMT</pubDate>
    <dc:creator>ChrisBrooks</dc:creator>
    <dc:date>2017-07-24T07:10:54Z</dc:date>
    <item>
      <title>Proc sql Language</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-Language/m-p/378584#M91015</link>
      <description>&lt;P&gt;My question is about the select statement and its usage.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Following is the code used to calculate average, i copied it from base sas codes avaiable online to understand function but can't understand why does it have "e. and d.". and what does it mean to say "class e class d",&lt;/P&gt;&lt;P&gt;Also need to understand the calcuation highlighted [in bold].&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step 1 &amp;nbsp;: Creating Data set&lt;/P&gt;&lt;P&gt;data class;&lt;BR /&gt;set sashelp.class;&lt;BR /&gt;obs = _n_;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step 2 : Proc Sql&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;select avg(weight) as Median&lt;BR /&gt;from (select&lt;STRONG&gt; e.&lt;/STRONG&gt;weight&lt;BR /&gt;from &lt;STRONG&gt;class e, class d&lt;/STRONG&gt;&lt;BR /&gt;group by &lt;STRONG&gt;e.&lt;/STRONG&gt;weight&lt;BR /&gt;&lt;STRONG&gt;having sum(case when e.weight = d.weight then 1 else 0 end)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;gt;= abs(sum(sign(e.weight - d.weight))));&lt;/STRONG&gt;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks !&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2017 06:29:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-Language/m-p/378584#M91015</guid>
      <dc:creator>JFario09</dc:creator>
      <dc:date>2017-07-24T06:29:12Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql Language</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-Language/m-p/378586#M91017</link>
      <description>&lt;P&gt;It may contribute to your understanding to know that you could just as well write&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;from class as e, class as d&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;e and d are simply the names you are using to refference you datasets, so you can refference them by&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select avg(weight) as Median
from (select e.weight&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Jul 2017 06:38:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-Language/m-p/378586#M91017</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-07-24T06:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql Language</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-Language/m-p/378587#M91018</link>
      <description>&lt;P&gt;Firstly e and d are aliases i.e. they are ways of referring to different variables in different data sets. In this particular case e and d both refer to the same data set and what is being produced is a cartesian product i.e. a data set which contains all possible combinations of weights (the table is being joined with itself).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The highlighted code is basically a complicated way of finding the median (i.e. the value with the same number of observations which are greater than it and which are less than it) by using the sum of differences. If you're using SAS 9.4 you can simply do this instead&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	select median(weight)
	from class;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Jul 2017 07:10:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-Language/m-p/378587#M91018</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2017-07-24T07:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql Language</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-Language/m-p/378589#M91020</link>
      <description>&lt;P&gt;Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;It worked when I used SAS 9.4.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2017 07:32:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-Language/m-p/378589#M91020</guid>
      <dc:creator>JFario09</dc:creator>
      <dc:date>2017-07-24T07:32:27Z</dc:date>
    </item>
  </channel>
</rss>

