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

what is broad cast agent? : Sas-bi

595


Explain what is the use of proc gplot?

702


how can you put a "trace" in your program? : Sas programming

579


What are the data types in sas?

608


What is run-group processing?

624






what do the pad and dim functions do? : Sas programming

566


Is the physical structure of the data set in the same orientation as the report? Do you need to reshape the data sets? What method should you use to reshape the data–DATA steps,PROC TRANSPOSE,output data set from a procedure?

1768


what is SAS OPTIMIZATION?

1817


what is information maps?

1616


What will calendar procedure do?

599


which date functions advances a date time or date/time value by a given interval? : Sas programming

537


What are types of transport files?

6864


How does SAS handle missing values in: assignment statements, functions, a merge, an update, sort order, formats, PROCs?

1098


What are the different versions of sas that you have used until now? : sas-grid-administration

734


what is enterprise guide? What is the use of it? : Sas programming

538