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

date1 =12001

Create a new variable Chdate that converts the date1 variable to a character variable that is in the format ddmonyyyy, such as 11NOV1992.

 

 

my prog :

Data X;

date1 =12001; 

Chdate=put(date1,9.);
format Chdate ddmonyyyy. ;

run;

output 

date1 Chdate

12001 12001 

 

Chdate should be in format ddmonyy. 

1 ACCEPTED SOLUTION
5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20
Data X;
   date1 = 12001; 
   Chdate = put(date1,date9.);
run;
librasonali
Quartz | Level 8
if date1 =201411
/*where initial 4 digits are year and rest months */
then what will be the format ?
Kurt_Bremser
Super User

@librasonali wrote:
if date1 =201411
/*where initial 4 digits are year and rest months */
then what will be the format ?

If that is stored as a number, you need to first convert it to a SAS date:

date1 = input(put(date1,z6.),yymmn6.);

for the DATE9. format to work. You will see that the resulting date is the first of the month.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 4294 views
  • 4 likes
  • 4 in conversation