Epoch
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
 
 

Display results as :
 


Rechercher Advanced Search

Keywords

Latest topics
» SAS Macro: Convert numbers (e.g., 1000) to names (e.g., One thousand)
Creating your own datetime format EmptyMon Jun 10, 2013 2:57 pm by Admin

» SAS Enterprise Guide: Explore Data before you start Analysing
Creating your own datetime format EmptyMon Jun 10, 2013 2:53 pm by Admin

» Predictive Analytics
Creating your own datetime format EmptyFri May 31, 2013 3:30 pm by Admin

» Creating Frequency Report and Creating User Defined styles in SAS Add-In for Microsoft Office
Creating your own datetime format EmptyTue Oct 23, 2012 2:11 pm by pallav

» Prompted Reports in BI Dashboard
Creating your own datetime format EmptyThu Oct 11, 2012 4:54 pm by kushal

» Free SAS Webinar : Getting Started with SAS Hash Object
Creating your own datetime format EmptyWed 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?
Creating your own datetime format EmptyTue Oct 02, 2012 12:47 am by rajin_kumar@yahoo.com

» What is written to SAS Log?
Creating your own datetime format EmptyTue Oct 02, 2012 12:39 am by rajin_kumar@yahoo.com

» SAS Portal and BI Dashboard: Customizing the Tabs
Creating your own datetime format EmptyTue Oct 02, 2012 12:33 am by kushal

Affiliates
free forum


Creating your own datetime format

Go down

Creating your own datetime format Empty Creating your own datetime format

Post  pallav 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);
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

Back to top Go down

Back to top

- Similar topics

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