Macro SAS - operacje na datach

Wednesday, January 7th, 2009 | SAS

http://analytics.ncsu.edu/sesug/2006/SC11_06.PDF

%let StartDate = %Sysevalf( ‘01JAN2004′d ) ;
%let EndDate = %Sysevalf( ‘01JAN2006′d ) ;

%let Date = %Sysfunc( InputN( 01JAN2006 , Date9 ) ) ;
%let Date2 = %Sysfunc( PutN( &Date , Date9 ) ) ;

%let NumOfMonths = %Sysfunc( Intck( Month , &StartDate , &EndDate ) ) ;
%let NewDate = %Sysfunc( Intnx( Month , &StartDate , &NumOfMonths ) ) ;

%Sysevalf - Evaluates arithmetic and logical expressions using floating-point arithmetic
%Sysfunc - Execute SAS functions (nie obsługuje funkcji put, input, lag i kilku innych)

By zapisać datę do stringa użyj kodu:


translate(put(data,ddmmyy10.),”-”,”/”) as moja_data format=$18.,
catx (” “, “Przypominamy, ze dnia”, calculated moja_data) as text

Tags:

No comments yet.

Leave a comment

Search