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 / guest
data dx;
infile datalines dsd dlm=',';
input parent :$8. child :$8.;
datalines;
A,B
B,C
D,E
F,G
G,H
H,I
;;;;
run;
data dy(rename=(parent=grandfather child=father)) ;
merge dx(firstobs=2 in =a rename=(child=grandchild
parent=child ))
dx(firstobs=1 in =b );
by child;
if a and b;
run;
proc print;
var grandfather father grandchild;
run;
| Is This Answer Correct ? | 15 Yes | 4 No |
Post New Answer View All Answers
Give an example where SAS fails to convert character value to numeric value automatically?
How might you use MOD and INT on numeric to mimic SUBSTR on character Strings?
How can I remove header from output data set?
What is the command used to find missing values?
explain the function of substr in sas? : Sas-administrator
what are input dataset and output dataset options? : Sas programming
what are some differences between proc summary and proc means? : Sas programming
name some data transformation used in sas di? : Sas-di
How to sort in descending order?
How to convert a numeric variable to a character variable?
what are the benefits of data integration? : Sas-di
How are numeric and character missing values represented internally?
What is the difference between %local and %global? : sas-macro
What is the purpose of trailing @ and @@? How do you use them?
what is operational data and operational system? : Sas-di