Date: Wed, 21 Jul 2010 09:36:41 -0400
Reply-To: Chang Chung <chang_y_chung@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Chang Chung <chang_y_chung@HOTMAIL.COM>
Subject: Re: Aaargh fomat/informat :-(
On Wed, 21 Jul 2010 06:54:06 +0000, Laughing Beggar
<laughing_beggar@HOTMAIL.COM> wrote:
...
>I have a character variable called sex that is variously coded 'M' or 'm'
or 'F' or 'f' and I want it to appear in a Proc Freq table as 'Male' and
'Female'.
>I thought I'd try doing it with a format or an informat but have fully
failed.
>Can it be done this way?
...
Hi, Mr. beggar:
Here is one way. Keep laughing! :-)
Cheers,
Chang
/* test data */
data one;
input id sex $ @@;
cards;
1 M 2 m 3 F 4 f 5 f
;
run;
proc format;
value $sex 'M','m' = 'Male' 'F','f' = 'Female';
run;
proc freq data=one;
tables sex;
format sex $sex.;
run;
/* on lst
The FREQ Procedure
Cumulative Cumulative
sex Frequency Percent Frequency Percent
-----------------------------------------------------------
Female 3 60.00 3 60.00
Male 2 40.00 5 100.00
*/
|