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?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.