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 |
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 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: