Hello all,
I'm encountering an irritating problem I was hoping to get some input on.
We have a global dates macro in our environment that I'm using to get a list of date variables. I'm using this for another program I'm writing.
The date I'm given from our gloal macro is formatted 'MM/DD/YYYY'. The variable &pdeg resolves to '09/23/2015'. I want to rearrange the date so that it's YYYYMMDD.
Here is my code:
%let date = %sysfunc(
cat(
%qsubstr(&pdeg,8,4),
%qsubstr(&pdeg,2,2),
%qsubstr(&pdeg,5,2)
)
);
The problem with this is that it's giving me the result of 2015923. I'm losing the 0. It's driving me crazy. I know there is a simple solution here but it's evading me. Appreciate any assistance!
Try
%let pdeg=09/23/2015;
%let date = %sysfunc(putn(%sysfunc(inputn(&pdeg,mmddyy10.)),yymmddn8.));
%put &date;
If your PDEG variable was built from something else It might be even easier to use that instead of a string.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.