data s ;
set sashelp.class ;
t=min(age,_n_) ;
run;
what is meaning of t=min(age,_n_) ?
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.
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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.