<?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 Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql/m-p/299671#M60465</link>
    <description>&lt;P&gt;I'm not a SQL expert, but I think it's useful to have another pair of eyes here.&amp;nbsp; Standard SQL syntax would remove the comma between Tag and From.&lt;/P&gt;</description>
    <pubDate>Tue, 20 Sep 2016 20:16:16 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-09-20T20:16:16Z</dc:date>
    <item>
      <title>Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql/m-p/299667#M60464</link>
      <description>&lt;P&gt;&lt;STRONG&gt;I have the following code where I use proc sql to identify readmits from claim data:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;Create Table all.readmits2 as&lt;BR /&gt;Select A.uidnum, A.DISD label = "Previous Discharge Date",&lt;BR /&gt;B.ADMD label = "Admission Date",&lt;BR /&gt;B.ADMD-A.DISD as Gap, 1 as Tag&lt;BR /&gt;From all.hssc_ub__shp_visits_match as A join all.hssc_ub__shp_visits_match as B&lt;BR /&gt;On A.uidnum = B.uidnum&lt;BR /&gt;Where&lt;BR /&gt;B.ADMD-A.DISD between 1 and 30;&lt;BR /&gt;Quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The coding works well and I am able to identify the approiate 30 day readmits however, I would like to include important demographic/utlization variables in my sql table (all_sex, all_age, all_race, all_race2, cond3, all_ip, all_ed, all_op, all_setting,). When I try to inculde these additional variables, I run into issues.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I used the following code and recieved the error message posted below:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;Create Table all.readmits4 as&lt;BR /&gt;Select A.uidnum, all_sex, all_age, all_race, all_race2, cond3, all_ip, all_ed, all_op, all_setting,&amp;nbsp;&lt;BR /&gt;A.DISD label = "Previous Discharge Date",&lt;BR /&gt;B.ADMD label = "Admission Date",&lt;BR /&gt;B.ADMD-A.DISD as Gap, 1 as Tag,&lt;BR /&gt;From all.hssc_ub__shp_visits_match as A join all.hssc_ub__shp_visits_match as B&lt;BR /&gt;On A.uidnum = B.uidnum&lt;BR /&gt;Where&lt;BR /&gt;B.ADMD-A.DISD between 1 and 30;&lt;BR /&gt;Quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error Message:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;199 From all.hssc_ub__shp_visits_match as A join all.hssc_ub__shp_visits_match as B&lt;BR /&gt;--- ----&lt;BR /&gt;22 76&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, (, *, **, +, ',', -, /,&lt;BR /&gt;&amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?, AND, BETWEEN, CONTAINS, EQ, EQT, FROM, GE, GET, GT, GTT,&lt;BR /&gt;LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;199! From all.hssc_ub__shp_visits_match as A join all.hssc_ub__shp_visits_match as B&lt;BR /&gt;----&lt;BR /&gt;22&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: a quoted string, ',', AS, FORMAT,&lt;BR /&gt;FROM, INFORMAT, INTO, LABEL, LEN, LENGTH, TRANSCODE.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;How can Inculde the additional variables in my SQL table?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Thanks,&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2016 20:08:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql/m-p/299667#M60464</guid>
      <dc:creator>melgwy</dc:creator>
      <dc:date>2016-09-20T20:08:58Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql/m-p/299671#M60465</link>
      <description>&lt;P&gt;I'm not a SQL expert, but I think it's useful to have another pair of eyes here.&amp;nbsp; Standard SQL syntax would remove the comma between Tag and From.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2016 20:16:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql/m-p/299671#M60465</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-09-20T20:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql/m-p/299675#M60466</link>
      <description>Hi, So when I remove the comma, I get the following errors:&lt;BR /&gt;&lt;BR /&gt;204 PROC SQL;&lt;BR /&gt;205 Create Table all.readmits4 as&lt;BR /&gt;206 Select A.uidnum, all_sex, all_age, all_race, all_race2, cond3, all_ip, all_ed,&lt;BR /&gt;206! all_op,all_setting,&lt;BR /&gt;207 A.DISD label = "Previous Discharge Date",&lt;BR /&gt;208 B.ADMD label = "Admission Date",&lt;BR /&gt;209 B.ADMD-A.DISD as Gap, 1 as Tag&lt;BR /&gt;210 From all.hssc_ub__shp_visits_match as A join all.hssc_ub__shp_visits_match as B&lt;BR /&gt;211 On A.uidnum = B.uidnum&lt;BR /&gt;212 Where&lt;BR /&gt;213 B.ADMD-A.DISD between 1 and 30;&lt;BR /&gt;ERROR: Ambiguous reference, column all_sex is in more than one table.&lt;BR /&gt;ERROR: Ambiguous reference, column all_age is in more than one table.&lt;BR /&gt;ERROR: Ambiguous reference, column all_race is in more than one table.&lt;BR /&gt;ERROR: Ambiguous reference, column all_race2 is in more than one table.&lt;BR /&gt;ERROR: Ambiguous reference, column cond3 is in more than one table.&lt;BR /&gt;ERROR: Ambiguous reference, column all_ip is in more than one table.&lt;BR /&gt;ERROR: Ambiguous reference, column all_ed is in more than one table.&lt;BR /&gt;ERROR: Ambiguous reference, column all_op is in more than one table.&lt;BR /&gt;ERROR: Ambiguous reference, column all_setting is in more than one table.&lt;BR /&gt;214 Quit;&lt;BR /&gt;&lt;BR /&gt;Any thoughts?&lt;BR /&gt;</description>
      <pubDate>Tue, 20 Sep 2016 20:23:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql/m-p/299675#M60466</guid>
      <dc:creator>melgwy</dc:creator>
      <dc:date>2016-09-20T20:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql/m-p/299680#M60467</link>
      <description>&lt;P&gt;Since those variables are in table A and B (reflexive joins are like that) prefix your "all" variables with A. just like you did for A.uidnum.&lt;/P&gt;
&lt;P&gt;A.all_sex, A.all_age etc.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2016 20:37:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql/m-p/299680#M60467</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-09-20T20:37:00Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql/m-p/299682#M60468</link>
      <description>&lt;P&gt;Well, now that the first error is gone we can move on to the next one.&amp;nbsp; These messages are telling you (for example) that ALL_SEX is in both of your incoming data sets.&amp;nbsp; Which one do you want to select, the one in A or the one in B?&amp;nbsp; Your program has to specify that.&amp;nbsp; So instead of:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;select all_sex,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to specify one of these:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;select A.all_sex,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;select B.all_sex,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You not only can choose, but you have to choose.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2016 20:37:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql/m-p/299682#M60468</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-09-20T20:37:57Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql/m-p/299695#M60470</link>
      <description>Thank you....I'm running the revised code now to see if it works.&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Tue, 20 Sep 2016 21:03:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql/m-p/299695#M60470</guid>
      <dc:creator>melgwy</dc:creator>
      <dc:date>2016-09-20T21:03:51Z</dc:date>
    </item>
  </channel>
</rss>

