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 / guest

data dx;
infile datalines dsd dlm=',';
input parent :$8. child :$8.;
datalines;
A,B
B,C
D,E
F,G
G,H
H,I
;;;;
run;

data dy(rename=(parent=grandfather child=father)) ;
merge dx(firstobs=2 in =a rename=(child=grandchild
parent=child ))
dx(firstobs=1 in =b );
by child;
if a and b;
run;
proc print;
var grandfather father grandchild;
run;

Is This Answer Correct ?    15 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the table names in oracle database...?

2255


Describe 5 ways to do a “table lookup” in SAS?

707


describe about physical data integration? : Sas-di

563


What is the basic syntax of a sas program?

673


how does sas handle missing values in functions? : Sas programming

606






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

545


What is the difference between order and group variable in proc report?

846


Explain the main difference between the sas procedures and functions? : Sas-administrator

542


Given an unsorted data set, how to read the last observation to a new data set?

845


what is program data vector? : Sas-administrator

621


What is the command used to find missing values?

595


what is change analysis in sas di ? : Sas-di

608


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

581


Do you know the features of sas?

598


what is null hypothesis? why do you consider that?

2425