kann es ein kürzerer Weg sein, aber dies funktionieren wird :
data have;
country = "INDIA";
pop = 200;
output;
country = "INDIA";
pop = 500;
output;
country = "INDIA";
pop = 300;
output;
country = "US";
pop = 1200;
output;
country = "US";
pop = 1400;
output;
country = "US";
pop = 900;
output;
country = "US";
pop = 1500;
output;
country = "INDIA";
pop = 700;
output;
run;
proc sort data=have;
by country descending pop;
run;
data have;
set have;
by country;
retain cnt;
if first.country then cnt = 1;
else cnt = cnt + 1;
run;
proc sql noprint;
create table want as
select country,pop from have
where cnt < 3;quit;
Ich weiß, dass es eine Sprachbarriere, aber können Sie ein wenig erläutern? – johnny
Identifizieren Sie die "letzten zwei" anhand der letzten zwei Datensätze basierend auf der Reihenfolge oder nach dem Betrag in der zweiten Variablen? – Reeza