how to write code for left outer join in SAs using datastep?
Answers were Sorted based on User's Feedback
Answer / uma
first sort these datasets by common variable DEPT_ID,Then
use the following:
data left_join;
merge emp (in=a) dept (in=b);
by dept_id;
if a then output;
run;
Is This Answer Correct ? | 22 Yes | 2 No |
Answer / aniruddha
Data left_outer;
merge emp(in=a) dept(in=b);
by deptno;
if a=1 and b=0;
run;
Is This Answer Correct ? | 22 Yes | 8 No |
Answer / lakshmi
data left_join;
merge data1(in=a) data2(in=b);
by subjid;
if a;
run;
Is This Answer Correct ? | 10 Yes | 3 No |
Answer / jbhjhj
dnt use set it wnt work.
use merge with in statements as above.
Is This Answer Correct ? | 8 Yes | 6 No |
Answer / venkatesh
if you use x=1 and y=0
you must use set statement also
try this
data a b;
merge one two;
by id;
if x=1 and y=1 then output a;
if x=1 and y=0 then output b;
data new;
set a b;
run;
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / raghava
proc sql;
select *
from one left join two
on one.X=two.X;
quit;
The above is code for lefjoin.
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / vk
Data Left_outer;
set data1(in=x) data2(in=y);
if x=0 and y=1;
run;
Is This Answer Correct ? | 9 Yes | 12 No |
Answer / pnprasad
There is no such Inner & Left Joins. In SAS only one join
i.e Right Join. If you want Left Join you have to use the
data set in the second place. For example: D1 D2 are the
data sets for D2 you want to make, UPDATE D1 D2;
Is This Answer Correct ? | 1 Yes | 22 No |
If you need the value of a variable rather than the variable itself what would you use to load the value to a macro variable? : sas-macro
What are the differences between sum function and using “+” operator?
how we can create a FLAG datasets? Ex:-ID age_group no_persons 1 to 10 10 to 20 3 11 to 20 21 to 30 7 21 to 3o 31 to 40 5
WHAT DOES A SAS SPECIFICATION DOCUMENT SDS CONTAIN ?
How we can create SAS USER DEFINED CODE?
Of all your work, where have you been the most successful?
For clinical entire study how many tables will create approx?
define table lookup and how may ways it can be done...explian
1.How to draw pivot tables in Excel by using SAS and in which version we can use VB script for to draw pivot tables in Excel? Answer with example data. 2.What are the advantages of _NULL_ in Data steps? Can we use _NULL_ in Proc steps also? 3. How to call the macro variable into Data Steps? 4. Can we draw pivot tables in Excel using Proc SQL? Please post answers for the above questions with suitable examples, and how to use VB script for Excel using SAS.
How to convert HTML file into SAS dataset?
Why and when do you use proc sql?
how many data types in sas? : Sas-administrator