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!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1272 views
  • 1 like
  • 3 in conversation