BookmarkSubscribeRSS Feed
deleted_user
Not applicable
some of my interviewees do not supply information
about their age at the first few interviews. How can I use the latter
information of their age to replace the information of their earlier
age. (interviews are conducted one time each year).
Thanks
4 REPLIES 4
Patrick
Opal | Level 21
I assume you would best save both date of interview and date of birth in your data - and then just replace the missing DoB in your older data via a merge over the id.

You should provide an example with sample data if you need a more specific answer.
deleted_user
Not applicable
Patrick,
my data like this:
id year age
100 2005 .
100 2006 .
100 2007 25
101 2005 .
101 2006 28
101 2007 29
102 2005 35
102 2006 36
102 2007 37
Thanks Message was edited by: vietst
GertNissen
Barite | Level 11
Try this simple sample

data input;
input id year age ;
datalines;
100 2005 .
100 2006 .
100 2007 25
101 2005 .
101 2006 28
101 2007 29
102 2005 35
102 2006 36
102 2007 37
;
run;

proc sort data=input;
by id descending year age;
run;

data output;
retain Rage;
set input;
by id;
if age ne . then Rage=age;
run;

You will need to implement some testing - i.e. what to do if the latest obs for an id is also missing age etc. etc. But I hope the above code will get you started in writing the code that will solve your problem.
Flip
Fluorite | Level 6
Here is another sollution for you.

[pre]
data one;
input id year age ;
datalines;
100 2005 .
100 2006 .
100 2007 25
101 2005 .
101 2006 28
101 2007 29
102 2005 35
102 2006 36
102 2007 37
;
run;

proc sort data = one;
by id year;
run;

data age;
set one (where = (aage ne .) rename = (year = ayear age = aage));
run;

data two (drop = aage ayear);
merge one age;
by id;
if age = . then age = aage - (ayear - year);
run;
[/pre]

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.

Explore Now →
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 2025 views
  • 0 likes
  • 4 in conversation