由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - SAS question using PROC SQL 高手请进, 包子答谢
相关主题
更新一下Taste of R,再问两个R的问题。【包子】求percentile问题
proc sql - SAS 10 包子请教再问一个sas输出的问题 (export)
问个PROC SQL中INNER JOIN的问题大家练练手吧,挺有意思的一道题
DATA step能left join吗?SAS应用问题
两个有关于R的小问题?请教一个用SAS作DATA MERGE的问题
再问R的问题 - 关于matrix 的operationSAS code help
借人 气问 两个 问题:请问一个SAS proc sql的写法
请教一下SAS编程的一个问题sas proc report的问题
相关话题的讨论汇总
话题: date1话题: data1话题: date2话题: data2话题: sql
进入Statistics版参与讨论
1 (共1页)
t**********r
发帖数: 182
1
Want to merge two data sets using proc sql:
Data1:
var1 var2 date1
Data2:
var1 var2 date2 rating
(Note: var1 and var2 are the same variables in these two data sets)
Question:
Select rating in data2 to data1; meeting the following criteria:
1. date1 - date2 >0
2. date1 - date2 has the minimum value.
I wrote the following code; but it won't work:
proc sql;
create table data3 as
select data1.*, data2.rating, date1-date1 as diff
from data1, data2
where data1.var1=data2.var1 a
s*r
发帖数: 2757
2
you have only 4

【在 t**********r 的大作中提到】
: Want to merge two data sets using proc sql:
: Data1:
: var1 var2 date1
: Data2:
: var1 var2 date2 rating
: (Note: var1 and var2 are the same variables in these two data sets)
: Question:
: Select rating in data2 to data1; meeting the following criteria:
: 1. date1 - date2 >0
: 2. date1 - date2 has the minimum value.

t**********r
发帖数: 182
3
4 what?
t**********r
发帖数: 182
4
Has figured it out. Thanks.
===============
579 proc sql;
580 create table data3 as
581 select data1.*, data2.rating, day1-day2 as diff
582 from data1, data2
583 where data1.var1=data2.var1 and data1.var2=data2.var2
584 and date1-date2>0
585 group by data1.var1, data1.var2, data1.date1
586 having diff=min(diff);
NOTE: The query requires remerging summary statistics back with the original
data.
NOTE: Table WORK.data3 created, with 48144 rows and 9 columns.
587 quit;
NOTE: PROCEDURE SQL used (Tota
y******0
发帖数: 401
5
proc sql;
create table data3 as
select data1.var1,data1.var2, data2.rating, min(date1-date2) as diff
from data1, data2
where data1.var1=data2.var1
and data1.var2=data2.var2
and date1>date2
group by 1,2,3;
quit;
m*********n
发帖数: 413
6
your code is wrong
functions could not be using in the HAVING subclasue.

【在 t**********r 的大作中提到】
: Want to merge two data sets using proc sql:
: Data1:
: var1 var2 date1
: Data2:
: var1 var2 date2 rating
: (Note: var1 and var2 are the same variables in these two data sets)
: Question:
: Select rating in data2 to data1; meeting the following criteria:
: 1. date1 - date2 >0
: 2. date1 - date2 has the minimum value.

1 (共1页)
进入Statistics版参与讨论
相关主题
sas proc report的问题两个有关于R的小问题?
SAS question: count non-missing value for different variables再问R的问题 - 关于matrix 的operation
[合集] how to calculate column sum not row sum in SAS? thanks a lo借人 气问 两个 问题:
另外请教rtf 文件中 控制pagebreak请教一下SAS编程的一个问题
更新一下Taste of R,再问两个R的问题。【包子】求percentile问题
proc sql - SAS 10 包子请教再问一个sas输出的问题 (export)
问个PROC SQL中INNER JOIN的问题大家练练手吧,挺有意思的一道题
DATA step能left join吗?SAS应用问题
相关话题的讨论汇总
话题: date1话题: data1话题: date2话题: data2话题: sql