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]

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register 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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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