BookmarkSubscribeRSS Feed
pawandh
Fluorite | Level 6

I want to find the min value.
data t;
input x;
cards;
10
20
40
30
26
;run;

 

i found this code


data t1;
set t end=last;
retain y;

y=min(y,x);
run;

And it's giving the right solution.I want to ask that initially the value of y is missing and if we using min(y,x) then it should come as missing value as missing value has the lowest priority, then how come it is coming 10 . Please explain.

 

 

 

 

 

3 REPLIES 3
user24feb
Barite | Level 11

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245915.htm

 

.. the min function only returns a missing value, if all arguments are missing. This is simply how the function works.

Kurt_Bremser
Super User

All those summary functions (max, min, sum, ...) have the advantage that they return a non-missing value as long as one of the arguments is non-missing. If you want a missing value treated as the minimum, you will have to code that manually.

Reeza
Super User

Although it works I would highly recommend using proc means instead. 

 

Proc means data=have stackods min max;
Var x;
ODS output summary=want;
Run;

Proc print data=want;
Run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 3 replies
  • 1282 views
  • 2 likes
  • 4 in conversation