Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Working with Timestamps in other Timezones

Status
Not open for further replies.

ks01

MIS
Aug 11, 2002
110
US
Hi everyone …

I’d like to ask if anyone knows or can suggest any SAS functions for working with and manipulating datetime values and time zones. I’m using SAS 9.1 running on z/OS. I will try to explain my objective.

I have seven separate SAS data sets for each day of the week and each SAS data set contains data related to that day’s work (e.g. Monday’s data set contains data related to jobs that ran on Monday, on a GMT calendar, etc…). Each SAS data set is refreshed the following week so the previous week’s data is lost if not obtained within that week.

Unfortunately, the time when these SAS data sets are populated with data is not consistent (e.g. run time of the job that populates these data sets vary, the job may be held, etc…).

My thought is to read in all SAS data sets to ensure that no data is missed and specify what records I need in my program. The timestamps in the input data sets are stored in DATETIME21.2 in the GMT time zone.

My dilemma is that I work in California and between the second Sunday of March and the first Sunday of November, I’m seven hours behind GMT (the rest of the year, I’ll be eight hours behind). I’m not sure if SAS has a function to determine the current time zone offset or if I have to manually code this.

Once written, the program will be added to a scheduler so no human interaction will be performed so the program needs to be able to run without any input other than the source data.

Does anyone have any suggestions?

Thanks in advance …

K
 
Hi K,
I've done a quick search in the SAS Doco and also the SAS Support site, but I can't find any functions or System variables to determine the Timezone, so that's 1 hurdle there.
If it is possible to get the Timezone, or your offset, from the system though, there might be a way.
"The X Command" or the SYSTASK command allows you to run system commands from SAS, so if you're comfortable working within z/OS and it's possible to get this info (I'm afraid I can't help there, I've never even seen one running) than this could well be the way to go.

Here's an example I used in Windows to get a list of all the text files in a directory (which I then later read in to SAS and used to build up a list of files to read in to loop through a macro and import them all:-
Code:
systask command "DIR /B ""&RAWPATH.\*.csv"" >Filelist.txt" WAIT;

I would hope that this would also work under z/OS in your environment. The text inside the quotes is what is passed to the system to run. WAIT tells SAS to wait until the command has finished running before continuing to the next step.
If you can do find a command to determine the offset on your system, then write/pipe that value to a file, you can then read that file in to SAS and you're basically there then. I'd then load that value into a macro variable and stick it anywhere in the program you need to know the offset.
The full doco for SYSTASK is here:-
The SAS doco site also has host specific info for z/OS which may or may not contain info about this command.

I hope that this helps.


Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top