Suppose there is a SAS dataset with following values -
Parent Child
A B
B C
D E
F G
G H
H I
and so on…..
This goes onto 1000s of observations/rows.
Now how do we identify from this dataset Grandparents and
Grandchildrens ?

Answer Posted / altumish

A simple self Join:

data old;
input Parent $ Child $;
cards;
A B
B C
D E
F G
G H
H I
I J
J K
J L
P S
;

Proc sql;
Select Old.parent as grandfather, Old.Child as father,
new.child as grandchild from work.Old as old, work.Old as new
where old.child = new.parent;
quit;

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

List out some key concept of SAS

613


How we can create SAS USER DEFINED CODE?

1605


Do you need to know if there are any missing values?

587


describe about metadata object? : Sas-di

616


Explain substr function?

569






what is sas application server? : Sas-di

530


Difference between SAS STATA & SPSS?

669


How do dates work in SAS data?

673


i have a dataset with 100 obs i want to generate title from 20th obs onwards with total observations. that should contain 100 obs.dont use firstobs and dnt split the data. use dataset block or proc report? how can we genarate;

1955


How do you test for missing values?

1053


what cause the "error: connect:" and "error in the libname statement" when there weren't any such problems?

1673


how does sas handle missing values in: assignment statements, functions, a merge, an update, sort order, formats, procs? : Sas programming

590


What do you understand by the term Normal Distribution?

563


Give some ways by which you can define the variables to produce the summary report (using proc report)?

589


Explain the use of proc gplot? : sas-grid-administration

545