BookmarkSubscribeRSS Feed
unwashedhelimix
Obsidian | Level 7

I have the following parts of some code I have:

 

 

proc import datafile="FILE_PATH" 
    out=sample_data 
    dbms=csv 
    replace;
    getnames=yes;
run;


/* get current date and time for titles in AM/PM format */
%let current_datetime = %sysfunc(datetime(), datetimeampm.);

proc sql;
    create table my_output as
    SQL Code
quit;

title1 "First Name & Last Name";
title2 "Date and Time: &current_datetime";
title3 "Title of Output";

proc print data=my_output; 
run;

However, the title2 in my output shows up as: 

Date and Time: 2048615388.473

 

Why isn't it showing in a MM/DD/YYYY AM/PM format? How can I fix it?

 

2 REPLIES 2
Tom
Super User Tom
Super User

SAS does not have FORMAT with that name.

69   %put current_datetime = %sysfunc(datetime(), datetimeampm.);
ERROR: Format name DATETIMEAMPM. not found or the width and/or decimal specified for the format used are out of range.
current_datetime = 2048627120.622

Did you mean to use the DATEAMPM format instead?  Or perhaps DATEAMPM23.?

70   %put current_datetime = %sysfunc(datetime(), dateampm.);
current_datetime = 30NOV24:11:08:28 PM
71   %put current_datetime = %sysfunc(datetime(), dateampm23.);
current_datetime =   30NOV2024:11:09:40 PM

 

Ksharp
Super User
%let current_datetime = %sysfunc(datetime(), mdyampm.);
title1 "First Name & Last Name";
title2 "Date and Time: &current_datetime";
proc print data=sashelp.class;
run;

Ksharp_0-1733032954735.png

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 447 views
  • 0 likes
  • 3 in conversation