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 the difference between order and group variable in proc report?
what is PhaseIII, ODS, TLG, Macro and Proc in SAS
what is ae onset date n what is RDS
what versions of sas have you used (on which platforms)? : Sas programming
why a stop statement is needed for the point= option on a set statement?
explain the function of substr in sas? : Sas-administrator
What are types of transport files?
How to read an input file in sas?
What is the basic structure of a sas program?
I need level 2 to 5 sas using companies in india
Explain how merging helps to combine data sets.
What is the command used to find missing values?
How do dates work in sas?
How do you specify the number of iterations and specific condition within a single do loop?
What is the difference between %put and symbolgen? : sas-macro