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!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 928 views
  • 0 likes
  • 2 in conversation