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 ;
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
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.
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
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.