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 many display types available in sas bi dashboard? : Sas-bi
How would you include common or reuse to be processed along with your statements?
What are the different types of sas functions?
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
What do the PUT and INPUT functions do?
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
How would you determine the number of missing or nonmissing values in computations?
what are some differences between proc summary and proc means? : Sas programming
how would you create multiple observations from a single observation? : Sas programming
Explain the main difference between the sas procedures and functions? : Sas-administrator
explain the difference between alternate key, business key, foreign key, generated key, primary key, retained key and surrogate key ? : Sas-di
Can you suggest us materials for sdtm mapping?
hi tell be about pfizer? how to compare the work with other companies ? please tell me how to login and work also?
how sas deals with business intelligence? : Sas-bi
Explain the special input delimiters used in sas programming.