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
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 |
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 |
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 |
i have one dataset data l; input name: $ 25; cards; manoj is a good boy to krishna krishna is a god boy to malli malli is good boy to ramana ques: here i want "manoj" observations nubers
how do i read multiple spaces in datasets? eg: vijaya raghava perumal.I tried with using & but it workss if its vijaya raghava but not for raghava perumal.how to do this?
How will you assign all the variables of an dataset into a macro variable separated by a space? For example if a dataset has variables A,B,C. Assign them to a macro variable X as X=A B C
How would you code a merge that will write the matches of both to one data set, the non-matches from the left-most data?
Give e an example of..
What are the ways in which macro variables can be created in sas programming?
Which are the statements whose placement in the data step is critical?
if i having variables named a b c d e f ,how to find total of each variable ????give syntax...??
How do you use the do loop if you don’t know how many times you should execute the do loop?
Can you execute macro within another macro? : sas-macro
Hi im new to sas. I have a file with some charecter variables and some numeric variables now i want to load charecter variables into one datastep and numeric variables into another data step pls let me know Thanks
How would you include common or reuse code to be processed along with your statements?