BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
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 ACCEPTED SOLUTION

Accepted Solutions
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;

 

View solution in original post

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;

 

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