proc sql;
title 'Employees with more than 30 Years of service as of December 31,2007';
select employee_name, intck('Year',employee_hire_date,'31dec2007'd) format=2.
YOS as 'Year of Service', mgr (select employee_name
from orion.employee_addresses
where a.employee_id=employee_organization.manager_id)
from orion.employee_addresses a ,orion.employee_payroll p
where a.employee_id=p.employee_id
having Year of Service >30
order by employee_name;
quit;
title;
That does not look like valid code. Let's look at it piece by piece.
Starts out ok. 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.
proc sql;
title 'Employees with more than 30 Years of service as of December 31,2007';
select employee_name
The start of the line looks sort of ok
, intck('Year',employee_hire_date,'31dec2007'd) format=2. YOS as 'Year of Service'
Not sure why you feel a need to attach a format to an integer. If the values is ever larger then 99 or smaller than -9 then trying to print it with only two characters will fail. The AS keyword goes before the name you want to give the variable not after.
And why not use the LABEL= keyword to attach the label?
This part makes no sense at all.
, mgr (select employee_name from orion.employee_addresses where .employee_id=employee_organization.manager_id)
This part seems normal
from orion.employee_addresses a
, orion.employee_payroll p
where a.employee_id=p.employee_id
This is strange
having Year of Service >30
You cannot just list three variable names in a row without any operators between them. Did you mean to reference the second column in your select statement that you appear to be trying to name as YOS?
The last clause looks fine.
order by employee_name;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.