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
Mention sas system options to debug sas macros.
how to debug and test the sas program? : Sas-administrator
what is data integration? : Sas-di
what is the difference between: x=a+b+c+d; and x=sum (of a, b, c ,d);? : Sas programming
what is enterprise guide? What is the use of it? : Sas programming
What is the use of %include statement?
What is maximum number of rows and cols can be handled in SAS?
Explain the difference between informat and format with an example.
what are the considerations when picking a SAS/STAT procedure?
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.
explain what is data set in sas? : Sas-administrator
Explain data step in SAS
explain the proc in sas? : Sas-administrator
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?
Enlist the syntax rules followed in sas statements.