Creating your own datetime format
Page 1 of 1
Creating your own datetime format
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);
run;
/*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.;
newdt=mydatetime;
put mydatetime= newdt=;
run;
The LOG shows: mydatetime=1574779496 newdt=25-11-2009 14:44:56
Creating a picture format:
proc format;
picture MyMSdt other='%0d-%0m-%0Y %0H:%0M:%0S' (datatype=datetime);
run;
/*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.;
newdt=mydatetime;
put mydatetime= newdt=;
run;
The LOG shows: mydatetime=1574779496 newdt=25-11-2009 14:44:56
pallav- Posts : 98
Join date : 2012-03-14
Location : Ahmedabad
Similar topics
» Creating Frequency Report and Creating User Defined styles in SAS Add-In for Microsoft Office
» SAS ODS Tip: Creating a Table of Contents
» Learn more about Picture Format
» Change in Base SAS Exam Format
» Which SAS procedure changes the name of a permanent format for a variable stored in a SAS data set?
» SAS ODS Tip: Creating a Table of Contents
» Learn more about Picture Format
» Change in Base SAS Exam Format
» Which SAS procedure changes the name of a permanent format for a variable stored in a SAS data set?
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|
Mon Jun 10, 2013 2:57 pm by Admin
» SAS Enterprise Guide: Explore Data before you start Analysing
Mon Jun 10, 2013 2:53 pm by Admin
» Predictive Analytics
Fri May 31, 2013 3:30 pm by Admin
» Creating Frequency Report and Creating User Defined styles in SAS Add-In for Microsoft Office
Tue Oct 23, 2012 2:11 pm by pallav
» Prompted Reports in BI Dashboard
Thu Oct 11, 2012 4:54 pm by kushal
» Free SAS Webinar : Getting Started with SAS Hash Object
Wed Oct 10, 2012 6:08 pm by pallav
» Which SAS procedure changes the name of a permanent format for a variable stored in a SAS data set?
Tue Oct 02, 2012 12:47 am by rajin_kumar@yahoo.com
» What is written to SAS Log?
Tue Oct 02, 2012 12:39 am by rajin_kumar@yahoo.com
» SAS Portal and BI Dashboard: Customizing the Tabs
Tue Oct 02, 2012 12:33 am by kushal