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

Mention sas system options to debug sas macros.

659


how to debug and test the sas program? : Sas-administrator

569


what is data integration? : Sas-di

610


what is the difference between: x=a+b+c+d; and x=sum (of a, b, c ,d);? : Sas programming

605


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

533






What is the use of %include statement?

617


What is maximum number of rows and cols can be handled in SAS?

849


Explain the difference between informat and format with an example.

678


what are the considerations when picking a SAS/STAT procedure?

2894


Assuming {et} is randomly drawn from N(0,1) and e0 = 0, generate 200 observations of xt = et − 0.5e(t−1) and draw a line graph of xt.

1457


explain what is data set in sas? : Sas-administrator

526


Explain data step in SAS

627


explain the proc in sas? : Sas-administrator

615


How would you code a merge that will write the matches of both to one data set, the non-matches from the left-most data?

634


Enlist the syntax rules followed in sas statements.

604