BookmarkSubscribeRSS Feed
thanikondharish
Calcite | Level 5

data s ;
set sashelp.class ;
t=min(age,_n_) ;
run;

 

what is meaning of   t=min(age,_n_)  ?

2 REPLIES 2
Jagadishkatam
Amethyst | Level 16

Here the function min is for minimum so it returns the minimum values of the variables and puts them in the new variable.

here _n_ returns the row number of the min(age,_n_) will compare the age with the row number or observation number and keeps the minimum of them in the new variable.

 

image.png

Thanks,
Jag
Kurt_Bremser
Super User

To be very correct here: _n_ is not the row number as such. It is the number of the current iteration of the data step. This very often correlates with either the row number of the input or output dataset, but it can very easily be different:

data s;
do until (eof);
  set sashelp.class end=eof;
  t=min(age,_n_);
end;
run;

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 551 views
  • 1 like
  • 3 in conversation