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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.