Is there anything in your dataset which denotes groups?
For the dataset as posted, I'd do
data second;
set have (keep=x rename=(x=xx));
n = _n_;
run;
proc sort data=second;
by n descending;
run;
data want;
merge
have
second (drop=n)
;
run;
Untested, posted from my tablet.
Is there anything in your dataset which denotes groups?
For the dataset as posted, I'd do
data second;
set have (keep=x rename=(x=xx));
n = _n_;
run;
proc sort data=second;
by n descending;
run;
data want;
merge
have
second (drop=n)
;
run;
Untested, posted from my tablet.
Alternatively, you can use a second SET statement with a POINT= option:
data want;
set have nobs=n;
_n_=n-_n_+1;
set have(keep=x rename=(x=xx)) point=_n_;
run;
@FreelanceReinh, I didn't notice your solution and wrote almost exactly the same 😄 😄
Bart
You can use the POINt= for this (no sorting).
data have;
input X Y Z;
cards;
10 11 21
2 12 22
40 13 23
4 14 24
80 15 25
;
run;
proc print data=have;
run;
data want;
set have nobs=nobs curobs=curobs;
point=nobs-curobs+1;
set have(keep=x rename=(x=xx)) point=point;
run;
proc print data=want;
run;
Bart
Just for some fun. Here is a SAS/IML solution.
data have;
input X Y Z;
cards;
10 11 21
2 12 22
40 13 23
4 14 24
80 15 25
;
run;
proc iml;
use have nobs nobs;
read all var {x y z};
close;
xx=x[nobs:1];
create want var {x y z xx};
append;
close;
quit;
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!Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.