BookmarkSubscribeRSS Feed
acordes
Rhodochrosite | Level 12

 

PIC.png

 

data casuser.test;
format timestamp datetime20.;
do i=1 to 100;
timestamp=intnx('dtminutes', datetime(), i);
output;
end;
drop i;
run;


proc cas;
   simple.summary result=sumres / 
      subset={'min', 'max'}, inputs={{name='timestamp', format='datetime20.' nfl=30, nfd=30}}, 
		attributes={{name='timestamp', format='datetime20.' nfl=30, nfd=30}},
		table={caslib="casuser",name="test"};
print sumres;
run;
1 REPLY 1
Stu_SAS
SAS Employee

Hey @acordes! One way to do this is to use the putn function on the Min/Max values in the result. For example:

proc cas;
   simple.summary result=sumres / 
      subset={'min', 'max'}, inputs={{name='timestamp', format='datetime20.' nfl=30, nfd=30}}, 
		attributes={{name='timestamp', format='datetime20.' nfl=30, nfd=30}},
		table={caslib="casuser",name="test"};

	print 'Min:' putn(sumres.summary[1, 'Min'], datetime20.);
	print 'Max:' putn(sumres.summary[1, 'Max'], datetime20.);
run;

 

Another option is to output the table and use table.fetch:

proc cas;
   simple.summary result=sumres / 
      subset={'min', 'max'}, inputs={{name='timestamp', format='datetime20.' nfl=30, nfd=30}}, 
		attributes={{name='timestamp', format='datetime20.' nfl=30, nfd=30}},
		table={caslib="casuser",name="test"}
		casout={caslib="casuser",name="outsum",replace=True};

	table.fetch / 
		table='outsum'
		fetchvars={{name='_min_', format='datetime20.'}
				   {name='_max_', format='datetime20.'}
		};
run;

 

Or, if you want to use a CAS-powered PROC, you can try MDSUMMARY and then print it with PROC PRINT:

proc mdsummary data=casuser.test;
	var timestamp;
	output out=casuser.outsum;
run;

proc print data=casuser.outsum;
	format _min_ _max_ datetime20.;
	var _min_ _max_;
run;

 

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

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
  • 1 reply
  • 283 views
  • 1 like
  • 2 in conversation