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 necessary is it to be creative in your work?

2013


List down the reasons for choosing sas over other data analytics tools.

799


what is the purpose of _error_? : Sas programming

600


what do the pad and dim functions do? : Sas programming

557


Difference between nodup and nodupkey options?

627






In proc transpose and data step with arrays which one you pick?

2567


What is the difference between proportion and average?

2746


How you are maintaining sas programmes in your company...any specific version control software you are using? If so, tell me the name?

1570


How do you add a number to a macro variable? : sas-macro

538


Differences between where and if statement?

577


how can you import .csv file in to sas? : Sas programming

628


What are pdv and it functions?

592


What is the good sas programming practices for processing large data sets?

621


do you prefer proc report or proc tabulate? Why? : Sas programming

565


State the difference between INFORMAT and FORMAT ?

585