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

Hello,

 

Could someone help me with converting a date to yyyymm (numeric)?  Here's how I would like to use my code:

 

%let xdate = '01NOV2018'd;
%let yymm = <code here to return 201811 as numeric>;

 

proc sql;
select *
from xx
where timeframe = &yymm;
quit;

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

Hi @jffeudo86 

 

%let xdate = '01NOV2018'd;
%let yymm = %sysfunc(putn(%sysevalf(&xdate),yymmn6.));
%put &=yymm;

I will not ask "why" 🙂

View solution in original post

4 REPLIES 4
jffeudo86
Quartz | Level 8

Please don't ask why do I have to use xdate and go straight to 201811.  

novinosrin
Tourmaline | Level 20

Hi @jffeudo86 

 

%let xdate = '01NOV2018'd;
%let yymm = %sysfunc(putn(%sysevalf(&xdate),yymmn6.));
%put &=yymm;

I will not ask "why" 🙂

jffeudo86
Quartz | Level 8
Thank you! That did the trick!
novinosrin
Tourmaline | Level 20

You're always welcome. Have a nice day! Cheers!

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1265 views
  • 0 likes
  • 2 in conversation