We want to merge file A and B. File A has variable age,
file B provide birthdate. How to merge the data according
to age in file B

Answers were Sorted based on User's Feedback



We want to merge file A and B. File A has variable age, file B provide birthdate. How to merge t..

Answer / ramesh

First calculate age in B datase


data age;
set b;
age=int(intck('day',bday,today())/365.25);
run;

sort both datasets by the age key variable and Use the
merge statement to combine the both datasets

Is This Answer Correct ?    10 Yes 1 No

We want to merge file A and B. File A has variable age, file B provide birthdate. How to merge t..

Answer / vishal

Calculate age in dataset B by using the following code:
data ages;
set b;
retain current;
if _n_=1 then current=today();
format bday current worddate20.;
age=int(intck('month',bday,current)/12);
if month(bday)=month(current) then
age=age-(day(bday)>day(current));
run;

Source: http://support.sas.com/kb/24/567.html

Is This Answer Correct ?    0 Yes 0 No

We want to merge file A and B. File A has variable age, file B provide birthdate. How to merge t..

Answer / alok karan

First calculate age in BB dataset:

data bbb;
set bb;
age=round(yrdif(birthdate,today(),'Actual'),1);
run;
proc sort data=bbb;
by age;
drop birthdate;
run;

Now merge both dataset by age variable:
data abc;
merge aa bbb;
by age;
run;

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SAS Interview Questions

How we can call macros with in data step? : sas-macro

0 Answers  


Are you familiar with special input delimiters? How are they used?

4 Answers   Accenture,


what is the difference between sas and other datawarehousing languages?what are the advantages of sas over them?

2 Answers   Accenture, Infosys,


what is the difference between proc means and proc tabulate?

3 Answers   Cognizant, CTS,


If a variable contains letters or special characters, can it be numeric data type?

0 Answers  


What are the rows present in protocol Violation table?

2 Answers   Accenture, Quintiles,


if i having variables named a b c d e f ,how to find total of each variable ????give syntax...??

6 Answers   Accenture,


Can you continue to write code while the rest of the people on the floor where you work have a noisy party to which you were not invited?

2 Answers   Oracle,


what is data integration? : Sas-di

0 Answers  


i want for interview question & answer plz it need immediate send t my mail raviprakashmot@gmal.cm

0 Answers   SAS,


i have a macro variable var1,var2. i want titles for the each macro variable separately? how it is possible?

1 Answers   L&T,


What is the purpose of _error_?

1 Answers   Quintiles,


Categories