As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.


Here are some tips for How to share your SAS knowledge with your professional network.


Tips:Creating your own datetime format

From sasCommunity
Jump to: navigation, search

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:

proc format;
  picture MyMSdt other='%0d-%0m-%0Y %0H:%0M:%0S' (datatype=datetime);
run;
 
data test;
  mydatetime='25nov2009 14:44:56'dt;
  format newdt MyMSdt.;
  newdt=mydatetime;
  put mydatetime= newdt=;
run;

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

See also Tips:Pound sign using picture format

....see also


Submitted by Alberto Negron. Contact me at my Discussion Page.