SAS calulations with multiple observations -


i'm trying compute value across observations. data like

id land decile distance   1    85   1       1.5   1    85   2       3.4   .   .   1    85   9       13.2   2    76   1       0.9 2    76   2       2.7 

i'm trying calculate each id ten deciles, (decile10 - decile(i+1))/(decile10 - decile1), ith decile. i'm not worried decile 10. help! been struggling day.

simple way multiple things on dataset: merge. here merge 10th decile onto 10 deciles, , use retain keep 1st decile value. there other approaches work if sorting difficulty, simplest if data aren't insanely large.

proc sort data=have;   id decile; run;  data merged;   merge have have(where=(decile=10) rename=(distance=distance_10 decile=decile10) keep=id decile distance);   id;   retain distance_1;   if first.id distance_1=distance; *assuming sorted id decile;   ... calculations, using distance_1 , distance_10 ... run; 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -