SAS Programming

DATA Step, Macro, Functions and more
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-white.png

Our biggest data and AI event of the 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.

 

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