HI,
I am looking to create a new column with max date. That mean my new column 'max_date should have 27jul2012 for all the caseid?
data have;
input caseid $ myDate date9.;
format myDate date9.;
datalines;
34 27jul2010
35 27jul2011
37 27jul2012
;
run;
Thanks in advance.
Output:
| caseid | myDate | maxDate |
| 34 | 27-Jul-10 | 27-Jul-12 |
| 35 | 27-Jul-11 | 27-Jul-12 |
| 37 | 27-Jul-12 | 27-Jul-12 |
Try this:
Proc sql;
Create table want as
Select *, max(myDate) as maxDate format date9.
from have
;Quit;
Output:
| caseid | myDate | maxDate |
| 34 | 27-Jul-10 | 27-Jul-10 |
| 35 | 27-Jul-11 | 27-Jul-11 |
| 37 | 27-Jul-12 | 27-Jul-12 |
Proc sql;
Create table want as select *, max(mydate) as max_date format=date. from have;
Quit;
Output:
| caseid | myDate | maxDate |
| 34 | 27-Jul-10 | 27-Jul-12 |
| 35 | 27-Jul-11 | 27-Jul-12 |
| 37 | 27-Jul-12 | 27-Jul-12 |
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 save with the early bird rate—just $795!
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.