Help using Base SAS procedures

missing value

Reply
N/A
Posts: 0

missing value

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
Respected Advisor
Posts: 3,887

Re: missing value

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.
N/A
Posts: 0

Re: missing value

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
SAS Employee
Posts: 160

Re: missing value

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.
Super Contributor
Posts: 359

Re: missing value

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]
Ask a Question
Discussion stats
  • 4 replies
  • 125 views
  • 0 likes
  • 4 in conversation