Hi all, I am a relatively new user to SAS, and very new to arrays, and I am trying to use an array to do the following.... I have a data set that looks like this (below), with data recorded once per month for 21 months (from Jan 2016 to Sept 2018). ID Start_Date Jan-2016 Feb-2016 March-2016 April-2016 .... Sept-2018 1 July 2015 2 6 1 9 ..... 7 2 August 2015 6 4 3 6 ..... 4 3 October 2015 8 2 5 5 ..... 8 For each participant, I need to grab the value from the columns that correspond with 6, 12, 18 and 24 months after an individual's Start_Date. So for example, for ID=1, because their start date is July 2015, I would need the values from the column Jan-2016(6mo), July-2016(12mo), Jan-2017(18mo), and July-2018(24mo) I would like my new data set to include 4 new variables as 4 new columns, with the titles 6mo, 12mo, 18mo, 24mo (as shown below). For each of those new variables, I would like the value to match that of the value under the corresponding month gap from the start date. ID Start_Date Jan-2016 Feb-2016 March-2016 April-2016 .... July-2018 6mo 12mo 18mo 24mo 1 July 2015 2 6 1 9 ..... 7 2 ... ... 7 2 August 2015 6 4 3 6 ..... 4 3 October 2015 8 2 5 5 ..... 8 The code I am starting with is below, but I haven't figured out how to adapt it to my specific scenario. data want; set have; array month{*} month1-month21; array newmonth{*} month1-month21; do i=1 to 21; newmonth{i}=month{start_date+i-1}; end; drop month: i; run; Hope this is helpful background. Any assistance is very much appreciated - thank you all in advance!
... View more