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.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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
  • 3502 views
  • 4 likes
  • 4 in conversation