Hi
I have following csv data
sample data:
id,created_date,modified_date
1021,12/23/2014 12:12:37 AM,9/21/2015 09:56:02 AM
1024,09/12/2015 04:24:00 PM,10/21/2015 11:44:03 AM
I have code:
DATA sample;
INFILE '/path/file' dsd dlm=',' firstobs=2 ;
ATTRIB
id informat = $5. format=$5.;
created_date informat=mdyampm. format=mdyampm.
modified_date informat=mdyampm. format=mdyampm. ;
INPUT id $ created_date Modified_date;
;run;
in My out put I am getting values for date variables like 9/21/2015 09:56:02 AM.
How Can I get dates like 9/21/2015 21:56:02 or datestamp (24 hours format without AM, PM). What is the right format I need to use for dates.
Thank you
If none of the OOTB formats is what you want..
...then you can always create your own picture format
http://support.sas.com/kb/24/621.html
If none of the OOTB formats is what you want..
...then you can always create your own picture format
http://support.sas.com/kb/24/621.html
Thank you for suggesting me PICTURE statement. Can we store customized date format in dataset?, I applied user defined format in PUT statement, PROC PRINT its working perfectly fine.
I have a dataset named Inventory as below:
Inv_no | Record_dt |
102 | 10Oct2015:14:00:00 |
103 | 12Oct2015:09:00:30 |
I tried with following code:
proc format;
picture limdate other='%0m/%0d/%0Y %0H:%0M:%0S' (datatype=datetime);
run;
data new_inv;
retain inv_no record_dt;
set inventory ;
format record_dt limdate.;
run;
but I am not successful.
so proc format Picture statement is only to display or presentation.???
Please suggest me if there is any way I can accomplish.
Thank you
All formats are "for display only" and you can assign a picture format permanently to a variable like any other type of format.
If you assign a format permanenly (eg. with a format statement) to a permanent dataset then please be aware that you also need to store the format itself into a permanent catalog (or re-run the Proc Format at the beginning of a new session).
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.