I followed "Convert Character variable / string YYYYMM in date" solved discussion and entered the following code:
PROC SQL;
CREATE TABLE WORK.QUERY_FOR_COMBINED_PANDG_MONTHLY AS
SELECT /* interval */
(input(t1.yr_mnth !! "01",yymmdd8.)) FORMAT=YYMMDD8. LABEL="interval" AS interval
FROM PLCP.COMBINED_PANDG_MONTHLY_VOLUMES t1;
QUIT;
However, the results came back as dot (.). Not sure what I did wrong. Any help will be greatly appreciated.
Thanks,
Greg
Either your variable is defined as longer than 6 characters, or it does not have full 6 digits. Or perhaps it is a number instead of a string? In which case it will get converted using the BEST12 format and so have 6 leading spaces before the 6 digit number.
You could use the CATS() function to insure the trailing and/or leading spaces are removed.
input(cats(t1.yr_mnth,"01"),yymmdd8.)
Either your variable is defined as longer than 6 characters, or it does not have full 6 digits. Or perhaps it is a number instead of a string? In which case it will get converted using the BEST12 format and so have 6 leading spaces before the 6 digit number.
You could use the CATS() function to insure the trailing and/or leading spaces are removed.
input(cats(t1.yr_mnth,"01"),yymmdd8.)
Thanks Tom, I just tried your code and it worked perfectly. I appreciate your help and continue to learn.
Greg
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.