Below is an interesting sample code:
* Get the first two max height values;
data _null_;
set sashelp.class end=last;
retain max1 max2;
call sortn(height, max2, max1);
if last then put "max height value: " max1 max2;
run;
SAS Senior Technical Consultant (twitter: @sasrunner)
Oakville, ON, Canada
Certified SAS Base/Advanced Programmer
Certified Data Integration Developer for SAS
Certified Platform Administrator for SAS
Certified Visual Business Analyst for SAS
SAS Certified Associate: Programming Fundamentals Using SAS Viya
SAS Certified Specialist: Intermediate Programming Using SAS Viya
* Get the first two max height values;
data _null_;
set sashelp.class end=last;
retain max1 max2;
call sortn(height, max2, max1);
if last then put "max height value: " max1 max2;
run;
* Sample;
data dummy;
set sashelp.class (obs=0);
run;
data test;
set sashelp.class;
if _n_ = 1 then do;
drop varexist dsid rc;
retain varexist;
dsid = open('dummy');
varexist = varnum(dsid, "name");
rc = close(dsid);
end;
length tmp $ 20;
if varexist then do;
tmp = vvaluex("name");
end;
else tmp = '';
run;
* Sample code;
proc sql;
select distinct sex, name
into:sex seperated by ' ', :name1-:name100
from sashelp.class;
%let num = &sqlobs;
quit;
%put Number: &sqlobs;
%put _global_;