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 many display types available in sas bi dashboard? : Sas-bi

635


How would you include common or reuse to be processed along with your statements?

1896


What are the different types of sas functions?

604


how we can create a FLAG datasets? Ex:-ID age_group no_persons 1 to 10 10 to 20 3 11 to 20 21 to 30 7 21 to 3o 31 to 40 5

1653


What do the PUT and INPUT functions do?

773






Hello Friends, am new to this forum and am not good at sas progarmming. please can any one of you send me couple of sample large sample SAS Jobs which can you use 200 MB of data and other sas job upto 25GB of data. am doing a performance testing on our legacy systems and new upgraded system. I would really appreciate if you can do me this favor Thank you Priya

1343


How would you determine the number of missing or nonmissing values in computations?

646


what are some differences between proc summary and proc means? : Sas programming

503


how would you create multiple observations from a single observation? : Sas programming

564


Explain the main difference between the sas procedures and functions? : Sas-administrator

533


explain the difference between alternate key, business key, foreign key, generated key, primary key, retained key and surrogate key ? : Sas-di

541


Can you suggest us materials for sdtm mapping?

4034


hi tell be about pfizer? how to compare the work with other companies ? please tell me how to login and work also?

1660


how sas deals with business intelligence? : Sas-bi

581


Explain the special input delimiters used in sas programming.

581