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
Describe the function and untility of the most difficult SAS macro that you have written.
Are you sensitive to code walk-throughs peer review or QC review?
what is sas olap server? : Sas-di
What are the functions used for character handling?
What are the difference between sas functions and procedures?
how to debug and test the sas program? : Sas-administrator
What are the best sas programming practices for handling very large datasets? : sas-grid-administration
hi tell be about pfizer? how to compare the work with other companies ? please tell me how to login and work also?
How can you limit the variables written to output dataset in data step?
What is the difference between INPUT and INFILE ?
In proc transpose and data step with arrays which one you pick?
How will you use the WHO Drug Dictionary for Reporting Clinical Trials?
What is program data vector (pdv)?
How do you delete duplicate observations in sas?
how can you import .csv file in to sas? : Sas programming