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
What are the table names in oracle database...?
Describe 5 ways to do a “table lookup” in SAS?
describe about physical data integration? : Sas-di
What is the basic syntax of a sas program?
how does sas handle missing values in functions? : Sas programming
which date functions advances a date time or date/time value by a given interval? : Sas programming
What is the difference between order and group variable in proc report?
Explain the main difference between the sas procedures and functions? : Sas-administrator
Given an unsorted data set, how to read the last observation to a new data set?
what is program data vector? : Sas-administrator
What is the command used to find missing values?
what is change analysis in sas di ? : Sas-di
how can you put a "trace" in your program? : Sas programming
Do you know the features of sas?
what is null hypothesis? why do you consider that?