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 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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