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
How necessary is it to be creative in your work?
List down the reasons for choosing sas over other data analytics tools.
what is the purpose of _error_? : Sas programming
what do the pad and dim functions do? : Sas programming
Difference between nodup and nodupkey options?
In proc transpose and data step with arrays which one you pick?
What is the difference between proportion and average?
How you are maintaining sas programmes in your company...any specific version control software you are using? If so, tell me the name?
How do you add a number to a macro variable? : sas-macro
Differences between where and if statement?
how can you import .csv file in to sas? : Sas programming
What are pdv and it functions?
What is the good sas programming practices for processing large data sets?
do you prefer proc report or proc tabulate? Why? : Sas programming
State the difference between INFORMAT and FORMAT ?