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 / sas@freek

data family;
input parent $ child $;
datalines;
A B
B C
C D
D E
E F
F G
G H
H I
;
run;
data family_new(drop=parent child);
set family;
parent1=lag(parent);
child1=lag(child);
grand_child=child;
if _n_ ge 2;
run;

proc print data=family_new;
var parent1 grand_child;
run;

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How sas treats the dsd delimiters?

724


what is the use of sas management console? : Sas-di

613


What sas features do you use to check errors and data validation?

693


hi all, I need the SAS DI DUMP(A00 260) for attending the certification. if any one have, pls provide it.Please Email to vrpotluri@hotmail.com. Thanks - Ramana

4914


What is the difference between %put and symbolgen? : sas-macro

671






what is metadata? : Sas-bi

600


If a variable contains only numbers, can it be a character data type?

613


State the difference between INFORMAT and FORMAT ?

599


What is the use of %include statement?

619


Explain the use of proc gplot? : sas-grid-administration

556


How we can create SAS USER DEFINED CODE?

1614


What are the difficulties u faced while doing vital signs table or dataset?

1938


How will you generate test data with no input data?

563


Did you used proc test? when?

1575


What are the data types that sas contain?

655