Display results as :

Rechercher Advanced Search


free forum

Creating your own datetime format

Go down

Creating your own datetime format Empty Creating your own datetime format

Post  pallav on Fri May 18, 2012 3:23 pm

The majority of the time the numeric formats provided in SAS are enough to deal with datetime values. However, there may be times when the formats provided do not meet our needs. Recently I've been asked to write out a SAS data set into a flat file and for a datetime variable the condition was to be written in the form of dd-mm-yyyy hh:mm:ss. The standard datetime format provided did not meet the requirement so in order to create the new format type I used the code below:

Creating a picture format:

proc format;
picture MyMSdt other='%0d-%0m-%0Y %0H:%0M:%0S' (datatype=datetime);

/*if its only date we use date constant, but if its date and time then we use date and time constant like variable = 'date time value'dt */

data test;
mydatetime='25nov2009 14:44:56'dt;

format newdt MyMSdt.;
put mydatetime= newdt=;

The LOG shows: mydatetime=1574779496 newdt=25-11-2009 14:44:56


Posts : 98
Join date : 2012-03-14
Location : Ahmedabad

Back to top Go down

Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum