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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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.)

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

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.)
gregor1
Quartz | Level 8

Thanks Tom, I just tried your code and it worked perfectly.  I appreciate your help and continue to learn.

Greg

ho0421
Fluorite | Level 6
This is very helpful. Thanks.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 6837 views
  • 1 like
  • 3 in conversation