Date: Thu, 22 Jun 2006 05:12:51 -0400
Reply-To: Jim Groeneveld <jim2stat@YAHOO.CO.UK>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jim Groeneveld <jim2stat@YAHOO.CO.UK>
Subject: Re: How to remove decimals from categorical variables?
Hi Jye,
Yes, I think the format 1. might be too small for certain variables with
values above 10 or below 0. Change the format to 2. or 3. and so on.
Regards - Jim.
--
Jim Groeneveld, Netherlands
Statistician, SAS consultant
home.hccnet.nl/jim.groeneveld
On Wed, 21 Jun 2006 20:48:12 -0700, Jye <wang0641@GMAIL.COM> wrote:
>Hi Jim,
>
>Hi, I did the way as you recommended and things seemed to work ok. But
>when I open the data file to view the it, the following error messages
>keep poping up and all the values in certain variables became *. In
>other words, in certain columns, all numbers got turned into *. Any
>suggestion what's going on and any solution?
>
>Here is the code I put in:
>
>DATA COMBINE1;
>SET COMBINE;
>FORMAT
>RES_ID AA2 AA4 AB2 A7A A7B A7C A7D A7E A7F A7G A7H A7I A7J B1 B2A B2B
>B4 D1 E1A E1D E1F E1H E1I E1L E1M
>G1AA G1BA G1EA G1GA G1HA G1IA G1JA G3A G3B G6A H1A H1B
>I1A I1F I1J I1L I1M I1O I1P I1T I1Y I1EE I1II I1QQ
>J2A J2B J4A J4B J5A J5B J5C K5B O1 P4A P4B P4C P4D P4E
>
>AA2_F AA4_F AB2_F A7A_F A7B_F A7C_F A7D_F A7E_F A7F_F A7G_F A7H_F A7I_F
>A7J_F B1_F B2A_F B2B_F B4_F D1_F E1A_F E1D_F
>E1F_F E1H_F E1I_F E1L_F E1M_F G1AA_F G1BA_F G1EA_F G1GA_F G1HA_F G1IA_F
>G1JA_F G3A_F G3B_F G6A_F H1A_F H1B_F
>I1A_F I1F_F I1J_F I1L_F I1M_F I1O_F I1P_F I1T_F I1Y_F I1EE_F I1II_F
>I1QQ_F
>J2A_F J2B_F J4A_F J4B_F J5A_F J5B_F J5C_F K5B_F O1_F P4A_F P4B_F P4C_F
>P4D_F P4E_F 1.;
>RUN;
>
>Here is the exact error message, seems like the number of error message
>is equal to the number of * in my column
>
>NOTE: Table has been opened in browse mode.
>ERROR: Asterisks are an indication of a format width problem.
>ERROR: Asterisks are an indication of a format width problem.
>ERROR: Asterisks are an indication of a format width problem.
>ERROR: Asterisks are an indication of a format width problem.
>ERROR: Asterisks are an indication of a format width problem.
>ERROR: Asterisks are an indication of a format width problem.
>ERROR: Asterisks are an indication of a format width problem.
>ERROR: Asterisks are an indication of a format width problem.
>ERROR: Asterisks are an indication of a format width problem.
>ERROR: Asterisks are an indication of a format width problem.
>ERROR: Asterisks are an indication of a format width problem.
>ERROR: Asterisks are an indication of a format width problem.
>ERROR: Asterisks are an indication of a format width problem.
>ERROR: Asterisks are an indication of a format width problem.
>ERROR: Asterisks are an indication of a format width problem.
>ERROR: Asterisks are an indication of a format width problem.
>ERROR: Asterisks are an indication of a format width problem.
>ERROR: Asterisks are an indication of a format width problem.
>ERROR: Asterisks are an indication of a format width problem.
>.....
>
>Thanks.
>
>Jye
>
>
>
>
>
>Jim Groeneveld wrote:
>> Hi Jye,
>>
>> In a data step or PROCs:
>> FORMAT <your_categorical_variable_list_here> 1.;
>> or:
>> PROC FORMAT;
>> VALUE _Gender;
>> 1 = 'male'
>> 2 = 'female'
>> ;
>> RUN;
>> and then in a data step or PROC for your variable Sex:
>> FORMAT Sex _Gender.;
>> This presents the textual labels (formats) for Sex, not values 1 and 2.
>> Likewise for other (categorical) variables.
>>
>> Regards - Jim.
>> --
>> Jim Groeneveld, Netherlands
>> Statistician, SAS consultant
>> home.hccnet.nl/jim.groeneveld
>>
>>
>> On Wed, 21 Jun 2006 13:00:44 -0700, Jye <wang0641@GMAIL.COM> wrote:
>>
>> >Hi,
>> >
>> >Some of the categorical variables in my database showed 5 digits after
>> >the decimal. Is there anyway to change it so that only numerical
>> >variables showed decimals while all categorical variables showed no
>> >decimals? For example, right now I have a gender variable, where
>> >1=male, 2=female. In the database it became 1.00000 and 2.00000. Same
>> >with race variables and a whole bunch of categorical variables. So all
>> >my output got these 5 digits decimals for all categorical variables. Is
>> >there a solution to this? I tried to change this in the "Column
>> >Attribute" option but everytime even if I save the setting, as soon as
>> >I reopen the databaes, it revert to those annoying 5 digits decimal
>> >again!
>> >
>> >Can I change the format in the database so all categorical variables
>> >show no decimals. Or if not, can I at least supress in my program so
>> >whenever I do some procedure, it will not show decimals for categorical
>> >variables. This just takes up too much space in the print out. It is
>> >also annoying.
>> >
>> >
>> >Thanks,
>> >
>> >Jye
|