1

I'm trying to create a table using a sql procedure with a column in date9 format, however, despite the put function I use with the date9 parameter, my column is created in string format, even though I have no error indicated in the log.

Here is what my code looks like:

rsubmit;
proc sql;
create table temp as (
    select put(intnx('month', datepart(MyDateTimeColumn), -1, 'e'),date9.) as FormatedDate
    from MyTable
);
quit;
endrsubmit;

Could you please help me?

Thanks in advance,

AZ

lemon
  • 14,875
  • 6
  • 18
  • 38
Alex Zak
  • 11
  • 2

1 Answers1

2

Why did you use the PUT() function if you did not want to create a string? FORMATS convert values into text.

If you want the date values to be displayed in ddMMMyyyy style then just attach the DATE9. format to the date variable.

proc sql;
create table temp as
  select intnx('month', datepart(MyDateTimeColumn), -1, 'e')
           as FormatedDate format=date9.
  from MyTable
;
quit;
Tom
  • 47,574
  • 2
  • 16
  • 29
  • I guess I had misunderstood this function, thanks – Alex Zak May 14 '22 at 18:46
  • Some people confuse FORMAT with variable TYPE. SAS only has two variable types, fixed length strings and floating point numbers. FORMATS are instructions for how to convert values into text. INFORMATS are instructions for how to convert text into values. – Tom May 14 '22 at 19:11