由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 一个SAS sql的问题
相关主题
加点料,世界最性感的5名女程序员请问:在C程序里能调用SAS的程序吗? (转载)
急问,在线等……h1b身份转行能否做contactor? (转载)请教一个SAS Macro问题。谢谢 (转载)
netflix employees: risk-free millionairesperl + sas - the backtick operator - use specific user
微软反面宣传人物是东亚裔和黑人 (转载)请问如何可以像run SAS, R一样的run python? (转载)
问一个java基础的初始化的问题,一直搞不明白Linux Market Share Passes 1%
Get promoted but no salary increase, accept it or not? (转make money by programing
H1B抽签前夕,湾区IT公司相继大裁员,大家都怎么看?何去何从 (转载)想学习MUMPS and Cache
找创业伙伴/实习机会问个有点怪的问题
相关话题的讨论汇总
话题: employees话题: salary话题: bonus话题: sales话题: hr
进入Programming版参与讨论
1 (共1页)
t**i
发帖数: 387
1
【 以下文字转载自 Statistics 讨论区 】
发信人: toni (toni), 信区: Statistics
标 题: 一个SAS sql的问题
发信站: BBS 未名空间站 (Mon Dec 30 16:18:39 2013, 美东)
刚接触SAS sql,有个问题求教:
现有2各表employees和bonus
employees表有列name, department, base_salary
bonus表有列year, department, bonus
现要用sql实现:返回employees表中所有的obs,用employees表中的department和year(
2012,2013)查询bonus表的bonus,给employees加上2列salary2012, salary2013
以下是我现有的一些code(不能同时返回2012和2013的total salary)
data employees;
input name $ dep $ base_salary;
datalines;
Charles Sales 70000
James HR 80000
Cindy HR 75000
Steven Sales 80000
;
data bonus;
input year dep $ bonus;
datalines;
2012 Sales 10000
2012 Marketing 12000
2012 HR 8000
2013 Sales 18000
2013 Marketing 20000
2013 HR 16000
;
proc sql;
select a.name, a.dep, a.base_salary, a.base_salary+b.bonus as salary2013
from employees a, bonus b where a.dep = b.dep and b.year=2013;
quit;
s******o
发帖数: 656
2
一个笨办法:
proc sql;
create table sa2013 as
select a.name, a.dep, a.base_salary, a.base_salary+b.bonus as salary2013
from employees a, bonus b
where a.dep = b.dep and b.year=2013;
create table sa2012 as
select a.name, a.dep, a.base_salary+b.bonus as salary2012
from employees a, bonus b
where a.dep = b.dep and b.year=2012;
create table salary as
select c.*, d.salary2012
from sa2013 c, sa2012 d
where c.name=d.name and c.dep=d.dep;
quit;

【在 t**i 的大作中提到】
: 【 以下文字转载自 Statistics 讨论区 】
: 发信人: toni (toni), 信区: Statistics
: 标 题: 一个SAS sql的问题
: 发信站: BBS 未名空间站 (Mon Dec 30 16:18:39 2013, 美东)
: 刚接触SAS sql,有个问题求教:
: 现有2各表employees和bonus
: employees表有列name, department, base_salary
: bonus表有列year, department, bonus
: 现要用sql实现:返回employees表中所有的obs,用employees表中的department和year(
: 2012,2013)查询bonus表的bonus,给employees加上2列salary2012, salary2013

1 (共1页)
进入Programming版参与讨论
相关主题
问个有点怪的问题问一个java基础的初始化的问题,一直搞不明白
andriod 入门问题Get promoted but no salary increase, accept it or not? (转
python入门请推荐一本书H1B抽签前夕,湾区IT公司相继大裁员,大家都怎么看?何去何从 (转载)
SAS在Linux环境下运行太难debug了 找创业伙伴/实习机会
加点料,世界最性感的5名女程序员请问:在C程序里能调用SAS的程序吗? (转载)
急问,在线等……h1b身份转行能否做contactor? (转载)请教一个SAS Macro问题。谢谢 (转载)
netflix employees: risk-free millionairesperl + sas - the backtick operator - use specific user
微软反面宣传人物是东亚裔和黑人 (转载)请问如何可以像run SAS, R一样的run python? (转载)
相关话题的讨论汇总
话题: employees话题: salary话题: bonus话题: sales话题: hr