Hello Experts,
I'm applying the following code :
proc standard data=bdd_1 mean=0 std=1 out=bdd_2 _std_data;
run;
proc distance data= bdd_2 _std_data method=euclid out=distances;
var interval (&var_all.);
id LIB;
run;
How do I retrieve the 5 maximum distances? Thank you for your help !
data bdd_1;
set sashelp.heart(obs=200);
keep _numeric_;
run;
proc standard data=bdd_1 mean=0 std=1 out=bdd_2_std_data;
run;
proc distance data= bdd_2_std_data method=euclid out=distances;
var interval (_numeric_);
run;
data temp;
set distances;
array x{*} _numeric_;
row=_n_;
do col=1 to _n_;
distance=x{col};output;
end;
keep row col distance;
run;
proc sort data=temp out=want;
by descending distance;
run;
proc print data=want(obs=5) noobs;
run;
data bdd_1;
set sashelp.heart(obs=200);
keep _numeric_;
run;
proc standard data=bdd_1 mean=0 std=1 out=bdd_2_std_data;
run;
proc distance data= bdd_2_std_data method=euclid out=distances;
var interval (_numeric_);
run;
data temp;
set distances;
array x{*} _numeric_;
row=_n_;
do col=1 to _n_;
distance=x{col};output;
end;
keep row col distance;
run;
proc sort data=temp out=want;
by descending distance;
run;
proc print data=want(obs=5) noobs;
run;
Thank you, Ksharp!
Hello @SASdevAnneMarie,
I'm sure you marked your own "thank you" post as the solution only by mistake. You can correct this easily: Select Ksharp's post as the solution after clicking "Not the Solution" in the option menu (see icon below) of the current solution.
Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.
Explore Now →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.