3

I am very new to SAS.

I want to convert Number to Character.

basically I want to use to_char function

so I try

proc sql;
select put(A.column,$11.) as new_column
from table A
quit;

This causing error,

what is appropriate way to convert Number to Character???

SASPYTHON
  • 1,571
  • 3
  • 14
  • 30
  • 1
    Character formats (the ones starting the `$`) are applied to character values. You need to use a numeric format, such as `11.` or `Z11.` if you want for apply it to your numeric values. – Tom Jan 24 '19 at 21:06

1 Answers1

6

You're close - you just need a numeric format, eg:

proc sql;
select put(A.column,11.) as new_column
  from table A;

(You also needed a closing semicolon)

See documentation: https://documentation.sas.com/?docsetId=lefunctionsref&docsetTarget=n0mlfb88dkhbmun1x08qbh5xbs7e.htm&docsetVersion=9.4&locale=en

Allan Bowe
  • 12,306
  • 19
  • 75
  • 124