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 are 5 ways to perform a table lookup in sas? : Sas-administrator
please can you tell me that in companies sas work are doing by through sas coding or sas wizard ??
what is metadata? : Sas-bi
Mention few capabilities of sas framework.
Difference between SAS STATA & SPSS?
If you could design your ideal job, what would it look like?
how does sas handle missing values in: assignment statements, functions, a merge, an update, sort order, formats, procs? : Sas programming
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 is a method for assigning first.var and last.var to the by groupvariable on unsorted data? : Sas programming
What does the trace option do?
What are the ways in which macro variables can be created in sas programming?
how many types of prompts are there? : Sas-bi
where to use sas business intelligence? : Sas-bi
i have a dataset with 100 obs i want to generate title from 20th obs onwards with total observations. that should contain 100 obs.dont use firstobs and dnt split the data. use dataset block or proc report? how can we genarate;
Hi, Does anybody has lastest SAS certification(base, adv., clinical)dumps,if anybody has please email me at mailtorajani76@gmail.com. Thanks