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;
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;
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.
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.