Good day!
I would like to combine two observations into a single observation.
data have;
infile datalines missover;
input cntno batchno min_dist l_day : date9. d_day : date9. ;
datalines;
0 389 598680.59 . 14JAN2025
751 0 0.00 18JAN2025
;
run;
The desired output should be a single observation with the following data:
751 389 598680.59 18JAN2025 14JAN2025
That is, I would like to remove zeros, blanks, and dots.
Version is 9.4
Thank you,
Jane
Quick and dirty
data have;
infile datalines missover;
input cntno batchno min_dist l_day : date9. d_day : date9. ;
datalines;
0 389 598680.59 . 14JAN2025
751 0 0.00 18JAN2025
;
run;
proc sql;
create table want as
select max(cntno) as cntno,
max(batchno) as batchno,
max(min_dist) as min_dist,
max(l_day) as l_day,
max(d_day) as d_day
from have;
quit;
Quick and dirty
data have;
infile datalines missover;
input cntno batchno min_dist l_day : date9. d_day : date9. ;
datalines;
0 389 598680.59 . 14JAN2025
751 0 0.00 18JAN2025
;
run;
proc sql;
create table want as
select max(cntno) as cntno,
max(batchno) as batchno,
max(min_dist) as min_dist,
max(l_day) as l_day,
max(d_day) as d_day
from have;
quit;
Perfect!
Thank you!
data have;
infile datalines missover;
input cntno batchno min_dist l_day : date9. d_day : date9. ;
format l_day d_day date9.;
datalines;
0 389 598680.59 . 14JAN2025
751 0 0.00 18JAN2025
;
run;
proc means data=have noprint;
var _numeric_;
output out=want(drop=_:) max=;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.