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


Please Help Members By Posting Answers For Below Questions

What is PDV?

716


What is the command used to find missing values?

583


What is factor analysis?

652


what are sas/access and sas/connect? : Sas programming

541


what is sas data set?

658






Name and describe few sas character functions that are used for data cleaning in brief.

658


What versions of SAS have you used (on which platforms)?

1006


What are the data types in sas?

598


what are validation tools that are used in sas? : Sas-administrator

586


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?

694


Give some ways by which you can define the variables to produce the summary report (using proc report)?

589


Have you used macros? For what purpose you have used? : sas-macro

550


Explain how you can debug and test your SAS program?

559


How to sort in descending order?

779


What are the scrubbing procedures in sas?

562