0
votes

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?

1
Show the statement you wrote using PUT function.data _null_
data null; dt = '27-03-2019'; format datevar1 date9.; datevar1 = input(dt, DDMMYY10.); datevar2 = cat("'", datevar1, "'d"); put datevar1; put datevar2; run;Felipe Markakis

1 Answers

2
votes

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);