BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
RichardAD
Quartz | Level 8

I would like to output a human readable datetime in a comment in some codegen.

filename codegen 'xyzzy.sas'; 
data _null_;
  file codegen ;
  now = datetime() ;
  put "/*" / " * Codegen created at " now ___FANCYFORMAT___ / " */" ;
run ;
data _null_;
  file codegen mod ;
  ... actual codegen
run ;
1 ACCEPTED SOLUTION

Accepted Solutions
RichardAD
Quartz | Level 8

Eventually found the NLDATM* family of formats.

NLDATMM. and NLDATMWZ. are close enough.

NLDATM.            23Jan2025:12:21:37
NLDATMAP.          January 23, 2025 12:21:37 PM
NLDATMDT.          January 23, 2025
NLDATML.           January 23, 2025 12:21:37 PM
NLDATMM.           Jan 23, 2025 12:21:37 PM            <------------
NLDATMMD.          January 23
NLDATMMDL.         January 23
NLDATMMDM.         Jan 23
NLDATMMDS.         01/23
NLDATMMN.          January
NLDATMS.           01/23/2025 12:21:37
NLDATMTM.          12:21:37
NLDATMTZ.          12:21:37 +0000
NLDATMW.           Thursday, January 23, 2025 12:21:37 PM
NLDATMWN.          Thursday
NLDATMWZ.          Thu, Jan 23, 2025 12:21:37 PM +0000    <--------
NLDATMYM.          January 2025
NLDATMYML.         January 2025
NLDATMYMM.         Jan 2025
NLDATMYMS.         01/2025
NLDATMYQ.          1st quarter 2025
NLDATMYQL.         1st quarter 2025
NLDATMYQM.         Q1 2025
NLDATMYQS.         2025/1
NLDATMYR.          2025
NLDATMYW.          week 03 2025
NLDATMZ.           23Jan2025:12:21:37 +0000

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

You want to use "directives" in PROC FORMAT. Here is the link (scroll down to directives) https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/proc/p0n990vq8gxca6n1vnsracr6jp2c.htm

 

Here is an example using directives: https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/proc/n01lvjtpz3ewuhn1cvj3x4yhzyul.htm#n01lvjt... It should be easy to modify this example to get exactly what you want.

 

 

--
Paige Miller
RichardAD
Quartz | Level 8

Eventually found the NLDATM* family of formats.

NLDATMM. and NLDATMWZ. are close enough.

NLDATM.            23Jan2025:12:21:37
NLDATMAP.          January 23, 2025 12:21:37 PM
NLDATMDT.          January 23, 2025
NLDATML.           January 23, 2025 12:21:37 PM
NLDATMM.           Jan 23, 2025 12:21:37 PM            <------------
NLDATMMD.          January 23
NLDATMMDL.         January 23
NLDATMMDM.         Jan 23
NLDATMMDS.         01/23
NLDATMMN.          January
NLDATMS.           01/23/2025 12:21:37
NLDATMTM.          12:21:37
NLDATMTZ.          12:21:37 +0000
NLDATMW.           Thursday, January 23, 2025 12:21:37 PM
NLDATMWN.          Thursday
NLDATMWZ.          Thu, Jan 23, 2025 12:21:37 PM +0000    <--------
NLDATMYM.          January 2025
NLDATMYML.         January 2025
NLDATMYMM.         Jan 2025
NLDATMYMS.         01/2025
NLDATMYQ.          1st quarter 2025
NLDATMYQL.         1st quarter 2025
NLDATMYQM.         Q1 2025
NLDATMYQS.         2025/1
NLDATMYR.          2025
NLDATMYW.          week 03 2025
NLDATMZ.           23Jan2025:12:21:37 +0000

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
  • 762 views
  • 4 likes
  • 2 in conversation