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
What is PDV?
What is the command used to find missing values?
What is factor analysis?
what are sas/access and sas/connect? : Sas programming
what is sas data set?
Name and describe few sas character functions that are used for data cleaning in brief.
What versions of SAS have you used (on which platforms)?
What are the data types in sas?
what are validation tools that are used in sas? : Sas-administrator
If you have a dataset that contains 100 variables, but you need only five of those, what is the code to force SAS to use only those variables?
Give some ways by which you can define the variables to produce the summary report (using proc report)?
Have you used macros? For what purpose you have used? : sas-macro
Explain how you can debug and test your SAS program?
How to sort in descending order?
What are the scrubbing procedures in sas?