DATA Step, Macro, Functions and more

problem with proc formats

Accepted Solution Solved
Reply
Contributor
Posts: 38
Accepted Solution

problem with proc formats

I am having a dataset with values yes/no. I want to use proc format to replace yes with 1 and no with 0.  

The dataset is attached for reference.


Accepted Solutions
Solution
‎08-17-2017 08:25 AM
Super User
Posts: 5,513

Re: problem with proc formats

Posted in reply to atulsingh

To create a format for a character variable, the format name must begin with $:

 

value $fmt 'No'='0'  'Yes'='1';

 

Alternatively, you could create an informat using INVALUE instead of VALUE.

View solution in original post


All Replies
Super User
Posts: 5,431

Re: problem with proc formats

Posted in reply to atulsingh

So what is your problem?

What have you tried?

Data never sleeps
Contributor
Posts: 38

Re: problem with proc formats

[ Edited ]

proc format;
value fmt 'No'= 0 'Yes'= 1;
run;

I am getting the error : 

proc format;
63 value fmt 'No'= 0 'Yes'= 1;
_
22
76
ERROR: The quoted string 'No' is not acceptable to a numeric format or informat.
ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a format name.
ERROR 76-322: Syntax error, statement will be ignored.
Contributor
Posts: 38

Re: problem with proc formats

Posted in reply to atulsingh

Please reply. I am stuck

Solution
‎08-17-2017 08:25 AM
Super User
Posts: 5,513

Re: problem with proc formats

Posted in reply to atulsingh

To create a format for a character variable, the format name must begin with $:

 

value $fmt 'No'='0'  'Yes'='1';

 

Alternatively, you could create an informat using INVALUE instead of VALUE.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 194 views
  • 0 likes
  • 3 in conversation