Help using Base SAS procedures

formats error

Reply
Super Contributor
Posts: 1,041

formats error

Hi,

I was trying to apply formats on a charecter variable and it gives a WARNING:

"VARIBALE HAS ALREADY BEEN DEFINED NUMERIC"????

I used like below

description=put(code,$format.);

Could you suggest me where i went wrong????

PROC Star
Posts: 7,471

Re: formats error

Posted in reply to robertrao

I would guess that you are trying to apply a character format to a numeric variable.  Possibly the following examples will help:

proc format;

  value $charformat

'1'='yes'

'2'='no';

  value numformat

1='yes'

2='no';

run;

data test;

  input charcode $ numcode;

  chardescription=put(charcode,$charformat.);

  numdescription=put(numcode,numformat.);

  cards;

1 1

2 2

;

Super Contributor
Posts: 1,041

Re: formats error

Hi Art,

Thanks for the reply.. Thats a charecter variable

Super User
Posts: 19,789

Re: formats error

Posted in reply to robertrao

Do you have a variable called description already in the dataset?

Super User
Super User
Posts: 7,042

Re: formats error

Posted in reply to robertrao

Your variable CODE is numeric and you are trying apply a character format (notice the leading dollar sign) to it.

229   proc format;

229 !              value $format '8'='eight';

NOTE: Format $FORMAT has been output.

229 !                                         run;

230   data x;

231    code=8 ;

232    description=put(code,$format.);

                            --------

                            484

WARNING: Variable code has already been defined as numeric.

NOTE 484-185: Format FORMAT was not found or could not be loaded.

233   run;

Ask a Question
Discussion stats
  • 4 replies
  • 269 views
  • 0 likes
  • 4 in conversation