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 does sas handle missing values in sort order? : Sas programming
What do you know about symput and symget?
Approximately what date is represented by the SAS date value of 730?
How would you determine the number of missing or nonmissing values in computations?
Mention how to limit decimal places for the variable using proc means?
where to use sas business intelligence? : Sas-bi
How to create list output for cross-tabulations in proc freq?
Mention some common errors that are usually committed in sas programming.
What is the difference between where and if statement?
How we can call macros with in data step? : sas-macro
What does proc print, and proc contents are used for?
what are the benefits of data integration? : Sas-di
What is the basic syntax style in SAS?
What is the role of unrestrictive users? : sas-grid-administration
Explain data_null_?