Hello
What is the way to convert SAS date into char value.
for example:
From SAS data value of 19FEB2019 I want to get following 3 values (in 3 different columns):
1902 (structure YYMM)
19/02 (structure YY/MM)
2019/02 (sructure YYYY/MM)
/**Convert SAS date into chat YYMM*/
/**Convert SAS date into chat YY-MM*/
/**Convert SAS date into chat YYYY/MM*/
Data new;
sas_date='19Feb2019';
wanted1=put(sas_date,???.);/*wanted char value 1902*/
wanted2=put(sas_date,???.);/*wanted char value 19-02*/
wanted3=put(sas_date,???.);/*wanted char value 2019/02*/
Run;
Data new;
sas_date='19Feb2019'd;
wanted1=put(sas_date,yymmd7.);/*YYYY-MM*/
wanted2=put(sas_date,yymmn4.);/*YYMM*/
wanted3=put(sas_date,yymmd9.);/*YYYY-MM*/
Run;
I found the error.
The sas_date was not date....
My question:
How to convert SAS date into char with structure MM/YYYY ?
How to convert SAS date into char with structure MM/YY ?
/**Convert SAS date into char */
/**Convert SAS date into char */
/**Convert SAS date into char */
Data new;
sas_date='19Feb2019'd;
wanted1=put(sas_date,yymmd7.);/*YYYY-MM*/
wanted2=put(sas_date,yymmn4.);/*YYMM*/
wanted3=put(sas_date,yymmd9.);/*YYYY-MM*/
wanted4=put(sas_date,???.);/*MM/YYYY*/
wanted5=put(sas_date,???.);/*MM/YY*/
Run;
Maxim 1: Read the Documentation. Scroll down to the "Date" category, and you'll find what you're looking for.
Big hint: if the year/month format is called YYMM, what would a developer call the format for month/year?
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
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.