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
What is a pdv and what are its functions?
What is the use of function Proc summary?
How will you react when, while consulting a SAS documentation manual to get an answer to a problem, someone says hey, I thought you were supposed to know all that stuff already, and not have to look it up in a book?
Mention how to limit decimal places for the variable using proc means?
what is the difference between calculating the 'mean' using the mean function and proc means? : Sas programming
How to test the debugging in sas?
what are several options for creating reports in web report studio? : Sas-bi
What commands are used in the case of including or excluding any specific variables in the data set?
explain the main difference between the nodup and nodupkey options? : Sas-administrator
What are the different servers in sas? : sas-grid-administration
Hi, If anyone has base SAS certification dumps, please share.
what are sas bi dashboard components? : Sas-bi
Describe crosslist option in tables statement?
What is slibref?
how do you want missing values handled? : Sas programming