BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jawhitmire
Quartz | Level 8

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

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

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;

View solution in original post

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

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;
jawhitmire
Quartz | Level 8

Perfect!  

Thank you!

novinosrin
Tourmaline | Level 20
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;
jawhitmire
Quartz | Level 8
Amazing! Short and sweet. Thank you!

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1431 views
  • 1 like
  • 3 in conversation