Help using Base SAS procedures

proc sql: how to assign length to constant char var?

Reply
Contributor
Posts: 36

proc sql: how to assign length to constant char var?

Hi,

How to assign length to constant char var? My code didn't work

proc sql;

     select 'abc' as name char(20)

     from xxx

     ;

Thanks.

Super Contributor
Posts: 334

Re: proc sql: how to assign length to constant char var?

Try

proc sql;

     select 'abc' as name length=20

     from xxx

     ;

quit;

EJ

Contributor
Posts: 36

Re: proc sql: how to assign length to constant char var?

Thank you so much!

Super Contributor
Posts: 334

Re: proc sql: how to assign length to constant char var?

IN SAS, since the value is in quotes you do not have to "declare" the variable as character as with some other languages. If you so desired you could change the length of numeric variables in the same way, but that comes with the lost of precision when moving from 8 bytes.

EJ

Ask a Question
Discussion stats
  • 3 replies
  • 203 views
  • 1 like
  • 2 in conversation