Help using Base SAS procedures

Why "others" (proc format) does not work here?

Accepted Solution Solved
Reply
Contributor
Posts: 36
Accepted Solution

Why "others" (proc format) does not work here?

Hi guys,

I want to reformat my data. If gender="M", I'll reformat it as 1.if others,  I'll reformat it as 0.  I wrote the codes as below. But it didn't work as expected.  Did I use "others" wrongly?  Thanks.

Tomi

proc format;

value $gender   "M"=1

                              others=0;

data have;

input gender $ @@;

datalines;

F M M G R T

;

run;

data want;

set have;

format gender $gender.;

run;


Accepted Solutions
Solution
‎12-14-2012 04:25 AM
Super Contributor
Posts: 276

Re: Why "others" (proc format) does not work here?

And you can apply your format in first data step also.

Don't required second data step..

proc format;

value $gender   "M"=1

                       OTHER=0;

data have;

input gender $ @@;

format gender $Gernder.;

datalines;

F M M G R T

;

run;

Thanks..

Sanjeev.K

View solution in original post


All Replies
Super Contributor
Posts: 276

Re: Why "others" (proc format) does not work here?

Hi Tomiking...

Small correction in your code...

Just write "OTHER" instead of "OTHERS".....:-)

Thanks & Regards

Sanjeev.K

Solution
‎12-14-2012 04:25 AM
Super Contributor
Posts: 276

Re: Why "others" (proc format) does not work here?

And you can apply your format in first data step also.

Don't required second data step..

proc format;

value $gender   "M"=1

                       OTHER=0;

data have;

input gender $ @@;

format gender $Gernder.;

datalines;

F M M G R T

;

run;

Thanks..

Sanjeev.K

Contributor
Posts: 36

Re: Why "others" (proc format) does not work here?

Posted in reply to kuridisanjeev

Got it. Thanks.

🔒 This topic is solved and locked.

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

Discussion stats
  • 3 replies
  • 158 views
  • 0 likes
  • 2 in conversation