Hi. this must be very basic question.
But I'm dealing with it for about... 12 hours. And I couldn't find the answer.
Data testtt;
Input group x1;
Cards;
1 1
1 10
1 30
2 100
2 1000
2 1200
3 30
3 43
3 77
;
Run;In the data above, I'd like to make a new variable which shows the last value of each group. (Or the biggest number of each group is also fine)
So it should be the data like this:
Data Result;
Input group x1 last;
Cards;
1 1 30
1 10 30
1 30 30
2 100 1200
2 1000 1200
2 1200 1200
3 30 77
3 43 77
3 77 77
;
Run;This must be the basic thing in SAS, but I couldn't find the way in SAS HELP or Google (or at least I don't know what to search...)
Thank you for the help in advance.
Data testtt;
Input group x1;
Cards;
1 1
1 10
1 30
2 100
2 1000
2 1200
3 30
3 43
3 77
;
Run;
proc sql;
create table want as
select *,max(x1) as max
from testtt
group by group;
quit;
biggest number
proc sql;
create table want as
select *,max(x1) as max
from have
group by group;
quit;
Data testtt;
Input group x1;
Cards;
1 1
1 10
1 30
2 100
2 1000
2 1200
3 30
3 43
3 77
;
Run;
proc sql;
create table want as
select *,max(x1) as max
from testtt
group by group;
quit;
biggest number
proc sql;
create table want as
select *,max(x1) as max
from have
group by group;
quit;
Thank you very much novinosrin!
Sql! That's what I should have learnt!
Have a nice day !
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.