Felipe Markakis
Felipe Markakis

Reputation: 187

Convert date9. to character

I'm trying to convert a sas date9. date to a character variable, but the problem, I guess, is that date9. actually has a numeric "julian" value, so when I try to pass it to a character variable, it dismisses the date9. format and becomes a number ("21635").

In other words, I have a variable date9. = 27MAR2019, with the value "21635", and I want a character variable char = "27MAR2019".

I tried using both put and input functions, but they only use the 'julian' value.

Can anyone give me a hand?

Upvotes: 0

Views: 8222

Answers (1)

Tom
Tom

Reputation: 51621

The number you are showing is the number of days since 1960. That is how SAS stores dates. If you want the FORMATTED value of a variable instead of the raw value of the variable you need to ask for it. For example by using the PUT() function

 newvar=put(oldvar,date9.);

or the VVALUE() function.

 newvar=vvalue(oldvar);

Upvotes: 2

Related Questions