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

If a variable contains letters or special characters, can it be numeric data type?

757


What is the length assigned to the target variable by the scan function?

670


why is a stop statement needed for the point=option on a set statement? : Sas programming

583


Explain how merging helps to combine data sets.

612


What is a put statement?

660






What do the sas log messages “numeric values have been converted to character” mean? What are the implications?

712


What are the five ways to do a table lookup in sas? : sas-grid-administration

588


What is factor analysis?

661


How would you define the end of a macro? : sas-macro

607


Describe the ways in which you can create a macro variable?

622


do you prefer proc report or proc tabulate? Why? : Sas programming

570


what is transformation in sas data integration? : Sas-di

550


What is connection profile? : sas-grid-administration

644


What is the difference between where and if statement?

619


what is the different between functions and procs that calculate the same simple descriptive statistics? : Sas programming

585