Hello, I need to create a variable (withdrawal_date) based off of the maximum date value for each participant id. I put in some fake data into this dataset to test some SAS codes to find a way to give me the maximum value across multiple variables, and then I need to make that value be the value of the created withdrawal_date variable. I found a macro to output the maximum variable, but it just gives me the variable name that has the max value. I am trying to figure out a way to code it so that the maximum value (not variable name) is output as the new variable. Raw "fake" data: id session1 session2 session3 session4 1 01/23/2019 02/01/2019 04/05/2019 06/01/2019 2 05/25/2019 07/02/2019 . . 3 04/07/2019 06/07/2019 09/09/2019 . 4 10/02/2019 10/28/2019 11/05/2019 . 5 03/04/2019 . . . 6 06/07/2019 07/04/2019 08/17/2019 10/01/2019 7 03/06/2019 03/27/2019 . . Macro: %macro test(dsn,vars,func); data new; set &dsn; array list(*) &vars; &func = vname(list[whichn(&func(of list[*]), of list[*])]); run; %mend test; /** retrieve maximum value from a b and c **/ %test(fake,session1 session2 session3 session4 session5,max) proc print; run; /** retrieve maximum value from all numeric variables **/ %test(fake,_numeric_,max) proc print; run; Output from macro: id session1 session2 session3 session4 max 1 01/23/2019 02/01/2019 04/05/2019 06/01/2019 session4 2 05/25/2019 07/02/2019 . . session2 3 04/07/2019 06/07/2019 09/09/2019 . session3 4 10/02/2019 10/28/2019 11/05/2019 . session3 5 03/04/2019 . . . session1 6 06/07/2019 07/04/2019 08/17/2019 10/01/2019 session4 7 03/06/2019 03/27/2019 . . session2 Desired output: id session1 session2 session3 session4 withdrawal_date 1 01/23/2019 02/01/2019 04/05/2019 06/01/2019 06/01/2019 2 05/25/2019 07/02/2019 . . 07/02/2019 3 04/07/2019 06/07/2019 09/09/2019 . 09/09/2019 4 10/02/2019 10/28/2019 11/05/2019 . 11/05/2019 5 03/04/2019 . . . 03/04/2019 6 06/07/2019 07/04/2019 08/17/2019 10/01/2019 10/01/2019 7 03/06/2019 03/27/2019 . . 03/27/2019 Thanks in advance!
... View more