由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - PROC SQL join data help
相关主题
珍惜生命,远离hsbc。[提问]怎样sort这个dataset?
sas adv 63题 52SAS problem ask for help!
问个PROC SQL中INNER JOIN的问题Please help with a SAS macro
完全不懂SAS,急请教一个问题sas programming question
SAS菜鸟请教如果使SAS的output的结果放到一个文件内?a sas merge question
问个效率问题 SQL vs data step,大数据量求一段SAS code
请教一sas programmm关于proc sql left join的一个问题
help for a sas question在SAS中不用proc sql的情况下实现inequality join
相关话题的讨论汇总
话题: drug话题: sql话题: join话题: proc话题: data
进入Statistics版参与讨论
1 (共1页)
p******s
发帖数: 229
1
There are 2 datasets, A and B. There is a variable called drug_id in each
dataset. How can we join thess 2 datasets and exclude drug_ids that exist
in B?
I know how to do it in DATA step (merge A (in=a) B (in=b); by drug_id; if a
and not b; run;), but have no idea how to do in PROC SQL.
Thank you.
h******e
发帖数: 1791
2
it is a left join.
select A.drug_id, , , ,
from A left join B on A.drug_id = B.drug_id
p******s
发帖数: 229
3
That is what I thought at first. but this way will keep drug_ids which are
in both A and B, besides those in A. Our purpose is to not include any drug_
ids that exist in B.
p******s
发帖数: 229
4
I got it by searching google.
the code is like this
select *
from A LEFT JOIN B
on A.drug_id = B.drug_id
where B.drug_id IS NULL
Thanks to hehehehe for the reply!
h******e
发帖数: 1791
5
学到一招,谢谢。

【在 p******s 的大作中提到】
: I got it by searching google.
: the code is like this
: select *
: from A LEFT JOIN B
: on A.drug_id = B.drug_id
: where B.drug_id IS NULL
: Thanks to hehehehe for the reply!

d******9
发帖数: 404
6
I guess all the values of variables from data B will be missing. If so, we
can also do it by SQL in 2 steps.
Proc SQL;
create table C as
select *
from A
where A.ID not in
(select ID from B);
quit;
proc sql;
create table Z as
select *
from C left join B
on C.ID=B.ID;
quit;
j******o
发帖数: 127
7
这招不错,学习了,谢谢。

【在 p******s 的大作中提到】
: I got it by searching google.
: the code is like this
: select *
: from A LEFT JOIN B
: on A.drug_id = B.drug_id
: where B.drug_id IS NULL
: Thanks to hehehehe for the reply!

n**m
发帖数: 156
8
use except in the join term
http://bama.ua.edu/sasv8/proc/zueryexp.htm
p******s
发帖数: 229
9
学习了,谢谢大家的贡献!
m*****y
发帖数: 229
10
I think the idea of hehehe is correct, but not necessary left join I think.
DATA A;
INPUT drug_id x;
datalines;
1 2
;
data B;
input drug_id y;
datalines;
1 4
;
proc sql;
select A.drug_id, x, y
from A,B
where A.drug_id=B.drug_id;
quit;
result:
drug_id x y

1 2 4

drug_

【在 p******s 的大作中提到】
: That is what I thought at first. but this way will keep drug_ids which are
: in both A and B, besides those in A. Our purpose is to not include any drug_
: ids that exist in B.

1 (共1页)
进入Statistics版参与讨论
相关主题
在SAS中不用proc sql的情况下实现inequality joinSAS菜鸟请教如果使SAS的output的结果放到一个文件内?
请教一sas code问个效率问题 SQL vs data step,大数据量
SAS DATA 求助请教一sas programmm
请教一个用SAS作DATA MERGE的问题help for a sas question
珍惜生命,远离hsbc。[提问]怎样sort这个dataset?
sas adv 63题 52SAS problem ask for help!
问个PROC SQL中INNER JOIN的问题Please help with a SAS macro
完全不懂SAS,急请教一个问题sas programming question
相关话题的讨论汇总
话题: drug话题: sql话题: join话题: proc话题: data