BookmarkSubscribeRSS Feed
iluvsas
Calcite | Level 5

I have a pipe delimited .txt file with the date in the below format. How do I convert it to a more meaningful sas date - 15DEC2012 9:20 PM

12-15-2011 09:20:30.000000PM


4 REPLIES 4
art297
Opal | Level 21

data have;

  infile cards dsd delimiter="|";

  informat dt anydtdtm28.;

  format dt datetime21.;

  input sex $ dt;

  cards;

M|12-15-2011 09:20:30.000000PM

F|10-02-2012 08:20:30.000000AM

;

shivas
Pyrite | Level 9

Hi,

If you want AM/PM then you can use dateampm format to display(using Art code and data).

data want;

  infile cards dsd delimiter="|";

  informat dt anydtdtm.;

  format dt dateampm16.;

  input sex $ dt;

  cards;

M|12-15-2011 09:20:30.000000PM

F|10-02-2012 08:20:30.000000AM

;

run;

Thanks,

Shiva

iluvsas
Calcite | Level 5

Hi, I have the input pipe delimited file in the below format with the fields -> id, sys date, tran_amount

10000000|Oct 14 2011 10:53:09:240PM|0.000000

I need to read the id as -> 10000000

sys_date as -> 14OCT2011 10:53 PM

tran_amount as -> 0.000000

and load the above values in the format defined above into a sas dataset.


iluvsas
Calcite | Level 5

The id datatype is int, sys_date is datetime and tran_amount is decimal(25,6)  from the source system.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 698 views
  • 0 likes
  • 3 in conversation