<?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 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/644074#M192329</link>
    <description>&lt;P&gt;Looks like institution is missing &amp;nbsp;on some rows&amp;nbsp;in one or more of your tables. Try excluding missing values from your joins:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;on a.institution=b.institution and a.institution ne ''&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Apr 2020 20:23:40 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2020-04-29T20:23:40Z</dc:date>
    <item>
      <title>proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/644070#M192328</link>
      <description>&lt;P&gt;I'm using proc sql to merge a few data sets (I know a merge data step would be easier but we have to use sql) and for some reason when I merge them its not showing observations from the same on group in the same line. For instance, for university of Missouri its showing the AA_apps, total_apps, and percent_AA in the same line as the university but is showing random numbers underneath that I'm not sure even go to the university of missouri. Heres my code and a picture of the output to visualize what I'm talking about. Basically each fact sheet has descriptive statistics on each race and I want to merge them to create one data set.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table all as&lt;/P&gt;&lt;P&gt;select *, coalesce (a.total_apps,b.total_apps,c.total_apps,d.total_apps,e.total_apps) astotal_apps&lt;/P&gt;&lt;P&gt;from facts1 a full join facts2 b&lt;/P&gt;&lt;P&gt;on a.institution=b.institution&lt;/P&gt;&lt;P&gt;full join facts3 c&lt;/P&gt;&lt;P&gt;on b.institution=c.institution&lt;/P&gt;&lt;P&gt;full join facts4 d&lt;/P&gt;&lt;P&gt;on c.institution=d.institution&lt;/P&gt;&lt;P&gt;full join facts5 e&lt;/P&gt;&lt;P&gt;on d.institution=e.institution;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="matoma_0-1588191077740.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/38889iDDE18B5485155905/image-size/medium?v=v2&amp;amp;px=400" role="button" title="matoma_0-1588191077740.png" alt="matoma_0-1588191077740.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2020 20:12:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/644070#M192328</guid>
      <dc:creator>matoma</dc:creator>
      <dc:date>2020-04-29T20:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/644074#M192329</link>
      <description>&lt;P&gt;Looks like institution is missing &amp;nbsp;on some rows&amp;nbsp;in one or more of your tables. Try excluding missing values from your joins:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;on a.institution=b.institution and a.institution ne ''&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2020 20:23:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/644074#M192329</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-04-29T20:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/644075#M192330</link>
      <description>&lt;P&gt;It is a good idea to actually specify the table.variable instead of select *. Especially when using multiple tables. If a variable exists in multiple tables which value you get may be a crap shoot. You may also want to use () to control which result is combined with which.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your comment about University of Missouri makes me think that you also should have at least one, if not for each source table a "where institution ='University of Missouri' such as&lt;/P&gt;
&lt;PRE&gt;from facts1 a full join 
   (select * from facts2 
    where institution='University of Missouri') b&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whenever I see a statement like "we have to use SQL" I always want to ask "do you use a hammer to dig a hole or a shovel to drive nails?". Both sort of work but the right tool for the task.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2020 20:25:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/644075#M192330</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-29T20:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/644084#M192333</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/299186"&gt;@matoma&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;.... but we have to use sql&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Sadly,&amp;nbsp;we are often confronted with statements like this here. I (and many, if not all other senior members of the communities) consider a statement like this a fallacy which can only come from a serious lack of SAS knowledge.&lt;/P&gt;
&lt;P&gt;The issue at hand shall define the tools to use. Please reconsider, or do everything in your power to make the "powers that be" reconsider. Otherwise, you'll throw computing resources, manpower, and time (together known as "money") out the window.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2020 20:55:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/644084#M192333</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-29T20:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/644104#M192344</link>
      <description>&lt;P&gt;A safer method would be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table inst as
select institution from facts1
union
select institution from facts2
union
select institution from facts3
union
select institution from facts4
union
select institution from facts5;

create table all as
select 
	i.institution, 
	a.AA_apps,
	a.percent_AA,
	b.AI_apps,
	b.percent_AI, 
	......
	coalesce (a.total_apps, b.total_apps, c.total_apps, d.total_apps, e.total_apps) as total_apps
from 
	inst as i left join 
	facts1 as a on i.institution=a.institution left join 
	facts2 as b on i.institution=b.institution left join 
	facts3 as c on i.institution=c.institution left join 
	facts4 as d on i.institution=d.institution left join 
	facts5 as e on i.institution=e.institution;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Are you sure you want COALESCE and not SUM?&lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2020 22:30:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql/m-p/644104#M192344</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-04-29T22:30:43Z</dc:date>
    </item>
  </channel>
</rss>

