SAS Procedures

Help using Base SAS procedures
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Benn
Calcite | Level 5

Hi Guys,

I have been trying to converting a date to a string of characters using the PUT function:

DATA WANT;

SET HAVE;

DATENEW=PUT(DATE, $8.);

RUN;

Currently my date is in the YYYYMMDD format. And the output of this code transformed the date into numbers:

19860108 becomes 9504

19860109 becomes 9505

So on and so forth. I think the output transformed the YYYYMMDD format into the SAS date format where 19600101 is zero.

How can I transform the YYYYMMDD into characters while keeping exactly what I see previously?

Thanks guys!

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Does this do what you want?:

DATA WANT;

  SET HAVE;

  DATENEW=PUT(DATE, yymmddn8.);

RUN;

View solution in original post

2 REPLIES 2
art297
Opal | Level 21

Does this do what you want?:

DATA WANT;

  SET HAVE;

  DATENEW=PUT(DATE, yymmddn8.);

RUN;

Astounding
PROC Star

You also have the alternative of leaving the data exactly as is.  When printing, you can always apply a format so you can view it in a more familiar form.  That also gives you flexibility of selecting the format you want for each report.  If you would like to assign a default format, you can add the FORMAT statement in the DATA step.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 234013 views
  • 7 likes
  • 3 in conversation