Help using Base SAS procedures

SAS sql remove format

Reply
Super Contributor
Posts: 271

SAS sql remove format

Hello everyone,

How I can remove variable y's format in proc sql?

proc sql noprint;

create table two as

select x,  y format=_null_ from one;

quit;

Thanks

SAS Super FREQ
Posts: 825

Re: SAS sql remove format

Posted in reply to GeorgeSAS

Hi George

Proc SQL expects a format name in the syntax, you could use a generic one like BEST. for numeric values. In order to remove a format from a variable, you can use Proc DATASETS.

Something like

proc datasets lib=work nolist;

  modify two;

    format y;

run;

  contents data=two;

run;

quit;

Will work

Super User
Super User
Posts: 8,127

Re: SAS sql remove format

Posted in reply to GeorgeSAS

No, one of the limitations of way that PROC SQL supports formats.

Now you could trick SAS into thinking you have created a NEW variable so not have the format (or the label for that matter) carried forward.

select x, y+0 as y ....

Contributor
Posts: 37

Re: SAS sql remove format

Will the trick you suggest work for character variables? I have all sorts of airport codes, e.g. KBOS maps to 'Logan International ...', but

sometimes I just want KBOS, so that I can save that in a macro variable that I later use as an argument to a macro.

 

Thanks, Bruce

Super User
Posts: 23,778

Re: SAS sql remove format

Posted in reply to GeorgeSAS
Use a plain jane character format.
Format=$50.
Contributor
Posts: 37

Re: SAS sql remove format

Ah, so easy. Thanks!
Ask a Question
Discussion stats
  • 5 replies
  • 1668 views
  • 1 like
  • 5 in conversation