```Date: Mon, 7 Dec 2009 03:02:11 -0800 Reply-To: NEFTAHA Sender: "SAS(r) Discussion" From: NEFTAHA Organization: http://groups.google.com Subject: Incremented variable calculating bthe number of the days Comments: To: sas-l@uga.edu Content-Type: text/plain; charset=ISO-8859-1 Hello, If anyone could help me, I am stuck. I would like to calculate the number of the days between a date under certain conditions: I have the date of the day and I would like to find the number of the days between this date and 3 months, between the date of the day and 6 months an so on for those date ( 1 YEAR, 2 YEAR, 3 YEAR .....30 YEARS). For this i use this code with the macro variable k witch does not incrementes, it is always at K=1. DATA SIM.MOIS (keep = DATE N) ; retain MOIS ; N = _N_ ; %let k = 1 ; DATE = date() ; MOIS = month(DATE) ; output ; %IF &k = 1 %then %do ; DATE = DATE + (7*13); MOIS2 = month(DATE) ; IF MOIS2 ne MOIS then do ; MOIS = month(DATE) ; %let k = %eval(&k+1) ; N=N+1 ; output ; end; %end; %else %do ; %IF &k = 2 %then %do; DATE = DATE + (7*26); MOIS2 = month(DATE) ; IF MOIS2 ne MOIS then do ; MOIS = month(DATE) ; %let k = %sysevalf(&k+1) ; output; end; %end; %else %do &k = 3 %TO 32 ; DATE = DATE + 365 ; MOIS2 = month(DATE) ; IF MOIS2 ne MOIS then do ; MOIS = month(DATE) ; %let k = %eval(&k+1) ; output ; end ; %end ; %end; Thank you for your help. NEFTAHA ```

Back to: Top of message | Previous page | Main SAS-L page