Hello Friends,
I want to search if a observation (date) in data set B1 is in data set A1 or not.
If obv in A1 found then print "found" else append the observation of B1 into A1.
data a1;
input date_file $;
datalines;
24NOV2011
25NOV2011
26NOV2011
27NOV2011
28NOV2011
;
data b1;
input date_file $;
datalines;
26NOV2011
30NOV2011
;
I try to use PROC COMPARE but it's not giving desirable result. Please help me out.
Thanks
Rohan,
Assume they are both sorted, then we can have:
data a1;
merge a1(in=a) b1(in=b);
by date_file;
if a then output;
if a and b then put "Found=" date_file;
else if b and not a then output;
run;
Regards,
Haikuo
I Have to create datasets with sysmonth, sysmonth-1 & Sysmonth-2 as the names, how can i do that?
Vijay, Since your screen name is different than the original poster's name, I'd suggest that you start a new discussion, provide an example "have" data set and an example "want" dataset.
show off my newly acquired hash skills:
data a1;
input date_file $;
datalines;
24NOV2011
25NOV2011
26NOV2011
27NOV2011
28NOV2011
;
data b1;
input date_file $;
datalines;
26NOV2011
30NOV2011
;
data _null_;
if _n_=1 then do;
declare hash ha(dataset:'b1', ordered: 'yes');
ha.definekey('date_file');
ha.definedata('date_file');
ha.definedone();
end;
set a1 ;
rc=ha.find();
if rc = 0 then put "Found=" date_file;
else ha.add();
ha.output(dataset:'ai_updated');
run;
Linlin
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.