LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (November 2006, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 8 Nov 2006 02:37:00 -0800
Reply-To:     ArjenR <Arjen.Raateland@YMPARISTO.FI>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         ArjenR <Arjen.Raateland@YMPARISTO.FI>
Organization: http://groups.google.com
Subject:      Re: Autocall macro containing other code?
Comments: To: sas-l@uga.edu
In-Reply-To:  <2932.212.127.7.18.1162909297.UFJIAWoISkt5.squirrel@212.127.7.18>
Content-Type: text/plain; charset="us-ascii"

Peter Crawford kirjoitti: > Probably you have an error in that macro which causes the proc statement > to be ignored. Would you like to let SAS-L see the macro ?

Yes, please see below. I also tried with the PROC FORMAT below the macro definition. Same results. The macro was not written by me. I have made a few changes, though. It was posted to SAS-L by Marianne Whitlock almost 4 years ago. See comments.

/******************************************************************/ /* STDTIME converts Eastern European Time (EET) or */ /* Middle European Time (MET) to Universal Time (UTC a.k.a. GMT). */ /* Daylight saving time is automatically taken into account. */ /* Please note that this file includes informat STDSHFT and */ /* format $DAYLITE, which are essential to proper operation! */ /******************************************************************/

/* This macro version assumes the use of daylight saving time between the last Sunday in March at 3.00 o'clock and the last Sunday in October at 4.00 o'clock (as is current practice in the EU).

Usage example:

The code lines below are part of data step where _aika_ is the original SAS datetime variable.

... UTC_DT=%STDTIME('02',_aika_); * Convert EET to UTC. ; UTC_D=datepart(UTC_DT); * Separate date and time parts. ; UTC_T=timepart(UTC_DT); ...

Alla sellaisenaan suorituskelpoinen esimerkki StdTime-makron soveltamisesta. Huomaa tiedostossa Esim_1_UTC rivillä 1 ja 2 päivämäärän korjaaminen ja siirtyminen kesäaikaan (yölliset kellonajat tekaistut ...).

* Makroa sisältävä tiedosto on sisällytettävä ohjelmaan, ; * koska tiedostossa on itse makron lisäksi PROC FORMAT. ; %include 'Y:\SAS\V9_Server\Makrot\StdTime.sas'; data Esim_1_UTC; set Esim.Esim_1(where=(time ne .));

* Convert EET to UTC. ; UTC_DT=%STDTIME('02',NHETKI);

* Separate date and time parts ; UTC_D=datepart(UTC_DT); UTC_T=timepart(UTC_DT); format UTC_DT eurdfdt20. UTC_D eurdfdd10. UTC_T hhmm6.; run;

This macro & its formats can be adapted to incorporate other time shifts, if needed. Please contact SAS support at SYKE/ICT unit.

Arjen Raateland, 15.02.2006, 04.10.2006, 03.11.2006 */

/* Original macro from a message posted to comp.soft-sys.sas on Thursday Dec 5, 2002 at 18:02 by Marianne Whitlock: "With those suggestions in mind, I am copying a macro which I used, originally written by Ian Whitlock, for standardizing times from different parts of the U.S."

Original comments in box below: */ /******************************************************************/ /* STDTIME returns Universal Time (UTC a.k.a. GMT) as a way of */ /* standardizing SAS datetime values for various locations. */ /* It returns a SAS datetime value for the location and time the */ /* user provides. */ /* User must create informat STDSHFT and format $DAYLITE. */ /* STDSHFT tells how many hours must be added to the date/time in */ /* the location to get UTC. */ /* $DAYLITE tells whether the location switches to daylight time. */ /******************************************************************/

/* Informat and format -- MUST be in existence when macro STDTIME is called. */ proc format ; invalue STDSHFT /* Time difference (hours) between local time and UTC time. */ "01" = -1 /* ~ MET zone */ "02" = -2 /* ~ EET zone */ ; value $DAYLITE /* Indicates whether daylight saving time is to be used. */ "01" = "YES" /* ~ MET zone */ "02" = "YES" /* ~ EET zone */ ; run;

%macro STDTIME(LOC,SASDTTM); %let YR = YEAR(DATEPART(&SASDTTM)); %let LASTSUNMAR = DHMS(INTNX("WEEK",MDY( 4,1,&YR)-1,0),3,0,0); %let LASTSUNOCT = DHMS(INTNX("WEEK",MDY(11,1,&YR)-1,0),4,0,0); ( &SASDTTM + 3600 * ( (input (&LOC,STDSHFT.)) - (((&LASTSUNMAR<=&SASDTTM<=&LASTSUNOCT) and (PUT(&LOC,$DAYLITE.)="YES" ))) ) ) %mend STDTIME;


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