<?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: Use SQL in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Use-SQL-in-SAS/m-p/469238#M119989</link>
    <description>&lt;P&gt;I would highly recommend you read up on SQL programming (ANSI) and proc sql, as you seem to be tying yourself up in knots by not understanding the basics.&lt;/P&gt;
&lt;P&gt;This:&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt; &lt;SPAN class="token statement"&gt;SELECT&lt;/SPAN&gt; Sasdata&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;Companies&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;psn_name &lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;/LI-CODE&gt;
&lt;P&gt;Is not valid, you can have up to two levels, &amp;lt;alias&amp;gt;.&amp;lt;variable&amp;gt;&lt;/P&gt;
&lt;P&gt;You create aliases in the from statement:&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;&lt;SPAN class="token keyword"&gt;FROM&lt;/SPAN&gt; Applications as ap &lt;SPAN class="token number"&gt;91&lt;/SPAN&gt; JOIN Personapplication ON ap&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;appln_id &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; Personapplication&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;appln_id &lt;SPAN class="token number"&gt;92&lt;/SPAN&gt; JOIN Companies ON Personapplication&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;person_id &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; Companies&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;person_id&lt;/LI-CODE&gt;
&lt;P&gt;So here, you have created and alias - ap - which refers to the dataset applications.&amp;nbsp; Do the same for your other tables.&amp;nbsp; In the from, you can provide: &amp;lt;library&amp;gt;.&amp;lt;dataset&amp;gt; as &amp;lt;alias&amp;gt;&lt;/P&gt;
&lt;P&gt;So:&lt;/P&gt;
&lt;PRE&gt;  select companies.psn_name,
         ...
  from   sasdata.applications as ap
  join   sasdata.personapplication as person
  on     ap.appln_id=person.appln_id
  join   sasdata.companies as companies
  on     person.appln_id=companies.appln_id
...&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;(Do note the consistent casing and indetations, makes for ease of reading.&lt;/P&gt;</description>
    <pubDate>Mon, 11 Jun 2018 13:55:05 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-06-11T13:55:05Z</dc:date>
    <item>
      <title>Use SQL in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-SQL-in-SAS/m-p/469195#M119967</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am planning to create a new table to count and show the number of 'appln_filing_id' per 'psn_name' per year (appln_filing_year) by using following codes,&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table number_of_application as
SELECT Sasdata.Companies.psn_name ,     
COUNT(distinct(case when appln_filing_year = 2006 then appln_filing_id end)) as "2006_application"
COUNT(distinct(case when appln_filing_year = 2006 and granted = 1 then appln_filing_id end)) as "2006_granted"
FROM Sasdata.Applications as ap 
JOIN Sasdata.Personapplication ON ap.appln_id = Sasdata.Personapplication.appln_id
JOIN Sasdata.Companies ON Sasdata.Personapplication.person_id = Sasdata.Companies.person_id
WHERE applt_seq_nr &amp;gt; 0
GROUP BY  psn_name        -- creates totals per name/country combination
ORDER BY psn_name
;

quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But the results show like this,&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;43   proc sql;
44   create table number_of_application as
45   SELECT Sasdata.Companies.psn_name ,
                             -
                             22
                             76
ERROR 22-322: Syntax error, expecting one of the following: a quoted string, !, !!, &amp;amp;, *, **, +,
              ',', -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?, AND, AS, BETWEEN, CONTAINS, EQ, EQT, FORMAT, FROM,
              GE, GET, GT, GTT, IN, INFORMAT, INTO, IS, LABEL, LE, LEN, LENGTH, LET, LIKE, LT, LTT,
              NE, NET, NOT, NOTIN, OR, TRANSCODE, ^, ^=, |, ||, ~, ~=.

ERROR 76-322: Syntax error, statement will be ignored.

46   COUNT(distinct(case when appln_filing_year = 2006 then appln_filing_id end)) as
46 ! "2006_application"
47   COUNT(distinct(case when appln_filing_year = 2006 and granted = 1 then appln_filing_id end)) as
47 !  "2006_granted"
48   FROM Sasdata.Applications as ap
49   JOIN Sasdata.Personapplication ON ap.appln_id = Sasdata.Personapplication.appln_id
50   JOIN Sasdata.Companies ON Sasdata.Personapplication.person_id = Sasdata.Companies.person_id
51   WHERE applt_seq_nr &amp;gt; 0
52   GROUP BY  psn_name        -- creates totals per name/country combination
53   ORDER BY psn_name
54   ;
55
56   quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Variables are extracted form Sasdata(Library)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;‘psn_name’ coming from ‘Sasdata.Companies’&lt;/P&gt;&lt;P&gt;‘appln_filing_id’, ‘appln_filing_year’ and ‘granted’ coming from ‘Sasdata.Applications’&lt;/P&gt;&lt;P&gt;Beside,&lt;/P&gt;&lt;P&gt;‘Sasdata.Companies’ and ‘Sasdata.Personapplication’ are linked by person_id;&lt;/P&gt;&lt;P&gt;‘Sasdata.Applications’ and ‘Sasdata.Personapplication’ are linked by appln_id;&lt;/P&gt;&lt;P&gt;Could you please give me some suggestion about this?&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 12:36:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-SQL-in-SAS/m-p/469195#M119967</guid>
      <dc:creator>France</dc:creator>
      <dc:date>2018-06-11T12:36:16Z</dc:date>
    </item>
    <item>
      <title>Re: Use SQL in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-SQL-in-SAS/m-p/469199#M119969</link>
      <description>&lt;P&gt;You don't need SASDATA. when referring to variable names in the SQL. Just use, for example, companies.psn_name&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 12:44:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-SQL-in-SAS/m-p/469199#M119969</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-06-11T12:44:23Z</dc:date>
    </item>
    <item>
      <title>Re: Use SQL in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-SQL-in-SAS/m-p/469207#M119976</link>
      <description>&lt;P&gt;hello Miller,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for your suggestion, but it is still wrong after deleting Sasdata.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;43   proc sql;
44   create table number_of_application as
45   SELECT Companies.psn_name ,
46   COUNT(distinct(case when appln_filing_year = 2006 then appln_filing_id end)) as
46 ! "2006_application"
     ------------------
     22
     76
ERROR 22-322: Expecting a name.

ERROR 76-322: Syntax error, statement will be ignored.

47   COUNT(distinct(case when appln_filing_year = 2006 and granted = 1 then appln_filing_id end)) as
47 !  "2006_granted"
48   FROM Applications as ap
49   JOIN Personapplication ON ap.appln_id = Personapplication.appln_id
50   JOIN Companies ON Personapplication.person_id = Companies.person_id
51   WHERE applt_seq_nr &amp;gt; 0
52   GROUP BY  psn_name
53   ORDER BY psn_name
54   ;
55
56   quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;could you please give me more suggestion?&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 12:54:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-SQL-in-SAS/m-p/469207#M119976</guid>
      <dc:creator>France</dc:creator>
      <dc:date>2018-06-11T12:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: Use SQL in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-SQL-in-SAS/m-p/469223#M119983</link>
      <description>&lt;P&gt;"2006_application" and "2006_granted" are strings, not variable names. Use application_2006 and granted_2006 instead (no quotes, of course).&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 13:14:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-SQL-in-SAS/m-p/469223#M119983</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-06-11T13:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: Use SQL in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-SQL-in-SAS/m-p/469224#M119984</link>
      <description>&lt;P&gt;"2006_application" is not a valid SAS name.&amp;nbsp; And before you take away the double quotes, 2006_application is also not a valid name.&amp;nbsp; Per something which you should read in the first examples on the language, variable names must start with a character or an underscore.&amp;nbsp; You can (although it is&amp;nbsp;&lt;U&gt;&lt;STRONG&gt;highly recommended you do not&lt;/STRONG&gt;&lt;/U&gt;) call it by using named literals:&lt;/P&gt;
&lt;P&gt;"2006_application"n&lt;/P&gt;
&lt;P&gt;However that is pretty bad practice in my opinion.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 13:15:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-SQL-in-SAS/m-p/469224#M119984</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-06-11T13:15:15Z</dc:date>
    </item>
    <item>
      <title>Re: Use SQL in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-SQL-in-SAS/m-p/469226#M119985</link>
      <description>&lt;P&gt;hello Bremser and RW9,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks both of you, the result looks like following after I revising the codes follow your suggestions.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;71   proc sql;
72   create table number_of_application as
73   SELECT Companies.psn_name ,
74   COUNT(distinct(case when appln_filing_year = 2006 then appln_filing_id end)) as
74 ! application_2006 ,
75   COUNT(distinct(case when appln_filing_year = 2006 and granted = 1 then appln_filing_id end)) as
75 !  granted_2006 ,
76   FROM Applications as ap
          ------------
          22
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, ',', -, '.', /, &amp;lt;,
              &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?, AND, AS, CONTAINS, EQ, EQT, FROM, GE, GET, GT, GTT, LE, LET,
              LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.

77   JOIN Personapplication ON ap.appln_id = Personapplication.appln_id
78   JOIN Companies ON Personapplication.person_id = Companies.person_id
79   WHERE applt_seq_nr &amp;gt; 0
80   GROUP BY  psn_name
81   ORDER BY psn_name
82   ;
83
84   quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;could you please give me more suggestion? &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;&amp;nbsp;thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 13:23:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-SQL-in-SAS/m-p/469226#M119985</guid>
      <dc:creator>France</dc:creator>
      <dc:date>2018-06-11T13:23:27Z</dc:date>
    </item>
    <item>
      <title>Re: Use SQL in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-SQL-in-SAS/m-p/469230#M119986</link>
      <description>&lt;P&gt;Well, off the bat you have an extra comma in there which shouldn't be:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;granted_2006 &lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 13:29:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-SQL-in-SAS/m-p/469230#M119986</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-06-11T13:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: Use SQL in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-SQL-in-SAS/m-p/469236#M119988</link>
      <description>&lt;P&gt;thanks for your suggestion. the result looks like below by following your method,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;85   proc sql;
86   create table number_of_application as
87   SELECT Companies.psn_name ,
88   COUNT(distinct(case when appln_filing_year = 2006 then appln_filing_id end)) as
88 ! application_2006 ,
89   COUNT(distinct(case when appln_filing_year = 2006 and granted = 1 then appln_filing_id end)) as
89 !  granted_2006
90   FROM Applications as ap
91   JOIN Personapplication ON ap.appln_id = Personapplication.appln_id
92   JOIN Companies ON Personapplication.person_id = Companies.person_id
93   WHERE applt_seq_nr &amp;gt; 0
94   GROUP BY  psn_name
95   ORDER BY psn_name
96   ;
ERROR: File WORK.APPLICATIONS.DATA does not exist.
ERROR: File WORK.PERSONAPPLICATION.DATA does not exist.
ERROR: File WORK.COMPANIES.DATA does not exist.
97
98   quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.26 seconds
      cpu time            0.03 seconds&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the datasets (APPLICATIONS, PERSONAPPLICATION, COMPANIES) are&amp;nbsp;included&amp;nbsp;in Sasdata (library), but when I add Sasdata in front of these datasets, the results look like below,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;99   proc sql;
100  create table number_of_application as
101  SELECT Sasdata.Companies.psn_name ,
                             -
                             22
                             76
ERROR 22-322: Syntax error, expecting one of the following: a quoted string, !, !!, &amp;amp;, *, **, +,
              ',', -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?, AND, AS, BETWEEN, CONTAINS, EQ, EQT, FORMAT, FROM,
              GE, GET, GT, GTT, IN, INFORMAT, INTO, IS, LABEL, LE, LEN, LENGTH, LET, LIKE, LT, LTT,
              NE, NET, NOT, NOTIN, OR, TRANSCODE, ^, ^=, |, ||, ~, ~=.

ERROR 76-322: Syntax error, statement will be ignored.

102  COUNT(distinct(case when appln_filing_year = 2006 then appln_filing_id end)) as
102! application_2006 ,
103  COUNT(distinct(case when appln_filing_year = 2006 and granted = 1 then appln_filing_id end)) as
103!  granted_2006
104  FROM Sasdata.Applications as ap
105  JOIN Sasdata.Personapplication ON ap.appln_id = Sasdata.Personapplication.appln_id
106  JOIN Sasdata.Companies ON Sasdata.Personapplication.person_id = Sasdata.Companies.person_id
107  WHERE applt_seq_nr &amp;gt; 0
108  GROUP BY  psn_name
109  ORDER BY psn_name
110  ;
111
112  quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;could you please give me some suggestion? thanks&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 13:47:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-SQL-in-SAS/m-p/469236#M119988</guid>
      <dc:creator>France</dc:creator>
      <dc:date>2018-06-11T13:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: Use SQL in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-SQL-in-SAS/m-p/469238#M119989</link>
      <description>&lt;P&gt;I would highly recommend you read up on SQL programming (ANSI) and proc sql, as you seem to be tying yourself up in knots by not understanding the basics.&lt;/P&gt;
&lt;P&gt;This:&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt; &lt;SPAN class="token statement"&gt;SELECT&lt;/SPAN&gt; Sasdata&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;Companies&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;psn_name &lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;/LI-CODE&gt;
&lt;P&gt;Is not valid, you can have up to two levels, &amp;lt;alias&amp;gt;.&amp;lt;variable&amp;gt;&lt;/P&gt;
&lt;P&gt;You create aliases in the from statement:&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;&lt;SPAN class="token keyword"&gt;FROM&lt;/SPAN&gt; Applications as ap &lt;SPAN class="token number"&gt;91&lt;/SPAN&gt; JOIN Personapplication ON ap&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;appln_id &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; Personapplication&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;appln_id &lt;SPAN class="token number"&gt;92&lt;/SPAN&gt; JOIN Companies ON Personapplication&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;person_id &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; Companies&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;person_id&lt;/LI-CODE&gt;
&lt;P&gt;So here, you have created and alias - ap - which refers to the dataset applications.&amp;nbsp; Do the same for your other tables.&amp;nbsp; In the from, you can provide: &amp;lt;library&amp;gt;.&amp;lt;dataset&amp;gt; as &amp;lt;alias&amp;gt;&lt;/P&gt;
&lt;P&gt;So:&lt;/P&gt;
&lt;PRE&gt;  select companies.psn_name,
         ...
  from   sasdata.applications as ap
  join   sasdata.personapplication as person
  on     ap.appln_id=person.appln_id
  join   sasdata.companies as companies
  on     person.appln_id=companies.appln_id
...&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;(Do note the consistent casing and indetations, makes for ease of reading.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 13:55:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-SQL-in-SAS/m-p/469238#M119989</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-06-11T13:55:05Z</dc:date>
    </item>
    <item>
      <title>Re: Use SQL in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-SQL-in-SAS/m-p/469239#M119990</link>
      <description>&lt;P&gt;For this, you use aliases:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table number_of_application as
select
  co.psn_name,
  count(distinct(case
    when appln_filing_year = 2006
    then appln_filing_id
  end)) as application_2006,
  count(distinct(case
    when appln_filing_year = 2006 and granted = 1
    then appln_filing_id
  end)) as granted_2006
from sasdata.applications as ap
join sasdata.personapplication as pe on ap.appln_id = pe.appln_id
join sasdata.companies as co on pe.person_id = co.person_id
where applt_seq_nr &amp;gt; 0
group by psn_name
order by psn_name
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Jun 2018 13:55:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-SQL-in-SAS/m-p/469239#M119990</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-06-11T13:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: Use SQL in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-SQL-in-SAS/m-p/469243#M119991</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194466"&gt;@France&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;thanks for your suggestion. the result looks like below by following your method,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;85   proc sql;
86   create table number_of_application as
87   SELECT Companies.psn_name ,
88   COUNT(distinct(case when appln_filing_year = 2006 then appln_filing_id end)) as
88 ! application_2006 ,
89   COUNT(distinct(case when appln_filing_year = 2006 and granted = 1 then appln_filing_id end)) as
89 !  granted_2006
90   FROM Applications as ap
91   JOIN Personapplication ON ap.appln_id = Personapplication.appln_id
92   JOIN Companies ON Personapplication.person_id = Companies.person_id
93   WHERE applt_seq_nr &amp;gt; 0
94   GROUP BY  psn_name
95   ORDER BY psn_name
96   ;
ERROR: File WORK.APPLICATIONS.DATA does not exist.
ERROR: File WORK.PERSONAPPLICATION.DATA does not exist.
ERROR: File WORK.COMPANIES.DATA does not exist.
97
98   quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.26 seconds
      cpu time            0.03 seconds&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the datasets (APPLICATIONS, PERSONAPPLICATION, COMPANIES) are&amp;nbsp;included&amp;nbsp;in Sasdata (library), but when I add Sasdata in front of these datasets, the results look like below,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;could you please give me some suggestion? thanks&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;You need to read more carefully. Earlier I said "You don't need SASDATA. when referring to variable names in the SQL." You should not remove SASDATA from the dataset names, only from the variable names.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 13:59:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-SQL-in-SAS/m-p/469243#M119991</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-06-11T13:59:04Z</dc:date>
    </item>
  </channel>
</rss>

