<?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: sas - sql error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/sas-sql-error/m-p/734638#M228829</link>
    <description>&lt;P&gt;That does not look like valid code.&amp;nbsp; Let's look at it piece by piece.&lt;/P&gt;
&lt;P&gt;Starts out ok.&amp;nbsp; Although why you would use SQL to print the results instead of making a dataset (or view) of the results and then printing them using normal printing tools like PROC PRINT or PROC REPORT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
title 'Employees with more than 30 Years of service as of December 31,2007';
select employee_name&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The start of the line looks sort of ok&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;, intck('Year',employee_hire_date,'31dec2007'd) format=2. YOS as 'Year of Service'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Not sure why you feel a need to attach a format to an integer.&amp;nbsp; If the values is ever larger then 99 or smaller than -9 then trying to print it with only two characters will fail.&amp;nbsp; The AS keyword goes before the name you want to give the variable not after.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And why not use the LABEL= keyword to attach the label?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;This part makes no sense at all.&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;, mgr (select employee_name from orion.employee_addresses where .employee_id=employee_organization.manager_id)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This part seems normal&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;from orion.employee_addresses a
   , orion.employee_payroll p
where a.employee_id=p.employee_id
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is strange&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;having Year of Service &amp;gt;30
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You cannot just list three variable names in a row without any operators between them.&amp;nbsp; Did you mean to reference the second column in your select statement that you appear to be trying to name as YOS?&lt;/P&gt;
&lt;P&gt;The last clause looks fine.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;order by employee_name;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 16 Apr 2021 04:01:42 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-04-16T04:01:42Z</dc:date>
    <item>
      <title>sas - sql error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-sql-error/m-p/734626#M228821</link>
      <description>&lt;PRE&gt;proc sql;&lt;BR /&gt;title 'Employees with more than 30 Years of service as of December 31,2007';&lt;BR /&gt;select employee_name, intck('Year',employee_hire_date,'31dec2007'd) format=2. &lt;BR /&gt;YOS as 'Year of Service', mgr (select employee_name &lt;BR /&gt;from orion.employee_addresses &lt;BR /&gt;where a.employee_id=employee_organization.manager_id)&lt;BR /&gt;from orion.employee_addresses a ,orion.employee_payroll p&lt;BR /&gt;where a.employee_id=p.employee_id&lt;BR /&gt;having Year of Service &amp;gt;30&lt;BR /&gt;order by employee_name;&lt;BR /&gt;quit;&lt;BR /&gt;title;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;DIV class="sasSource"&gt;OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;72&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;73 proc sql;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;74 title 'Employees with more than 30 Years of service as of December 31,2007';&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;75 select employee_name, int('31dec2007'd-employee_hire_date/365.25) format=2.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;76 YOS as 'Year of Service',mgr (select employee_name&lt;/DIV&gt;&lt;DIV class="sasError"&gt;___ _____________&lt;/DIV&gt;&lt;DIV class="sasError"&gt;22 76&lt;/DIV&gt;&lt;DIV class="sasError"&gt;202&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR 22-322: Syntax error, expecting one of the following: a quoted string, ',', AS, FORMAT, FROM, INFORMAT, INTO, LABEL, LEN,&lt;/DIV&gt;&lt;DIV class="sasError"&gt;LENGTH, TRANSCODE.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR 202-322: The option or parameter is not recognized and will be ignored.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;76 ! YOS as 'Year of Service',mgr (select employee_name&lt;/DIV&gt;&lt;DIV class="sasError"&gt;_____________&lt;/DIV&gt;&lt;DIV class="sasError"&gt;22&lt;/DIV&gt;&lt;DIV class="sasError"&gt;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,&lt;/DIV&gt;&lt;DIV class="sasError"&gt;BETWEEN, CONTAINS, EQ, EQT, GE, GET, GT, GTT, IN, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ^, ^=, |, ||,&lt;/DIV&gt;&lt;DIV class="sasError"&gt;~, ~=.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;77 from orion.employee_addresses&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;78 where a.employee_id=employee_organization.manager_id)&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;79 from orion.employee_addresses a ,orion.employee_payroll p&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;80 where a.employee_id=p.employee_id&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;81 having Year of Service &amp;gt;30&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;82 order by employee_name;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;83 quit;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;real time 0.00 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;cpu time 0.01 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Apr 2021 03:21:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-sql-error/m-p/734626#M228821</guid>
      <dc:creator>bumchum</dc:creator>
      <dc:date>2021-04-16T03:21:39Z</dc:date>
    </item>
    <item>
      <title>Re: sas - sql error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-sql-error/m-p/734638#M228829</link>
      <description>&lt;P&gt;That does not look like valid code.&amp;nbsp; Let's look at it piece by piece.&lt;/P&gt;
&lt;P&gt;Starts out ok.&amp;nbsp; Although why you would use SQL to print the results instead of making a dataset (or view) of the results and then printing them using normal printing tools like PROC PRINT or PROC REPORT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
title 'Employees with more than 30 Years of service as of December 31,2007';
select employee_name&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The start of the line looks sort of ok&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;, intck('Year',employee_hire_date,'31dec2007'd) format=2. YOS as 'Year of Service'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Not sure why you feel a need to attach a format to an integer.&amp;nbsp; If the values is ever larger then 99 or smaller than -9 then trying to print it with only two characters will fail.&amp;nbsp; The AS keyword goes before the name you want to give the variable not after.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And why not use the LABEL= keyword to attach the label?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;This part makes no sense at all.&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;, mgr (select employee_name from orion.employee_addresses where .employee_id=employee_organization.manager_id)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This part seems normal&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;from orion.employee_addresses a
   , orion.employee_payroll p
where a.employee_id=p.employee_id
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is strange&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;having Year of Service &amp;gt;30
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You cannot just list three variable names in a row without any operators between them.&amp;nbsp; Did you mean to reference the second column in your select statement that you appear to be trying to name as YOS?&lt;/P&gt;
&lt;P&gt;The last clause looks fine.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;order by employee_name;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 04:01:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-sql-error/m-p/734638#M228829</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-16T04:01:42Z</dc:date>
    </item>
  </channel>
</rss>

