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

/*i have the following dataset.*/ data score; input marks ; datalines; 10 20 30 40 50 60 70 80 90 100 ; run; Now i should get the result as sum of 1 to 5 i.e(10+20+30+40+50)=150 and 2 to 6 i.e(20+30+40+50+60)=200 and 3 to 7 i.e(30+40+50+60+70)=250 and so on. how to get it. thanks in advance

2 Answers   Eval Source,


what is the use of catalog?

1 Answers   Cognizant,


How to test the debugging in sas?

0 Answers  


How to import the Zip files into SAS? If it is possible in SAS? If it is posible write the code...

7 Answers  


What is difference between Global n Local Macro Variables..?

6 Answers   TCS,






how to display duplicated observations in a data using base sas.

13 Answers   HCL, TCS,


How do you debug and test your SAS programs? What can you learn from the SAS log when debugging? How do you test for missing values? How would you create multiple observations from a single observation? What are some good SAS programming practices for processing very large data sets? Briefly describe 5 ways to do a "table lookup" in SAS. Why is SAS considered self-documenting? Are you sensitive to code walk-throughs, peer review, or QC review? What other SAS features do you use for error trapping and data validation? How does SAS handle missing values in: assignment statements, functions, a merge, an update, sort order, formats, PROCs?

2 Answers  


what does .. meant in sas macros

3 Answers   D&B,


What is the length assigned to the target variable by the scan function?

0 Answers  


what is sas metadata repository? : Sas-bi

0 Answers  


what is sas metadata server? : Sas-di

0 Answers  


How do you test for missing values?

0 Answers   Quintiles,


Categories