From: litonchen on 9 Aug 2010 21:44 I have a problem about cross table. The following is a data example. Type($) original_data(8.) modified_data(8.) A 0.32 0.45 B 0.62 0.70 .... .... There are 3 columns, and original_data and modified_data are between 0~1. I want to produce the following cross table. Type Value sum_of_original_data Sum_of_modified_data A 0~0.5 A 0.5~1 B 0~0.5 B 0.5~1 How to produce the cross table??
From: Ya on 9 Aug 2010 23:12 On Aug 9, 6:44 pm, "litonc...(a)gmail.com" <litonc...(a)gmail.com> wrote: > I have a problem about cross table. The following is a data example. > > Type($) original_data(8.) modified_data(8.) > A 0.32 0.45 > B 0.62 0.70 > ... > ... > > There are 3 columns, and original_data and modified_data are between > 0~1. I want to produce the following cross table. > > Type Value sum_of_original_data Sum_of_modified_data > A 0~0.5 > A 0.5~1 > B 0~0.5 > B 0.5~1 > > How to produce the cross table?? Try this: data have; set have; val=orig; if 0<val<=0.5 then rnge='0~0.5'; else rnge='0.5~1'; vnm='Orig'; output; val=modi; if 0<val<=0.5 then rnge='0~0.5'; else rnge='0.5~1'; vnm='modi'; output; run; proc tabulate data=have; class type rnge vnm; var val; table type=''*rnge='',vnm=''*val=''*sum=''; run; HTH Ya
From: litonchen on 10 Aug 2010 04:25 On 8æ10æ¥, ä¸å11æ12å, Ya <huang8...(a)gmail.com> wrote: > On Aug 9, 6:44 pm, "litonc...(a)gmail.com" <litonc...(a)gmail.com> wrote: > > > > > > > I have a problem about cross table. The following is a data example. > > > Type($)  original_data(8.)   modified_data(8.) > > A       0.32          0.45 > > B       0.62          0.70 > > ... > > ... > > > There are 3 columns, and original_data and modified_data are between > > 0~1. I want to produce the following cross table. > > > Type  Value  sum_of_original_data    Sum_of_modified_data > > A    0~0.5 > > A    0.5~1 > > B    0~0.5 > > B    0.5~1 > > > How to produce the cross table?? > > Try this: > > data have; >  set have; > val=orig; if 0<val<=0.5 then rnge='0~0.5'; else rnge='0.5~1'; > vnm='Orig'; output; > val=modi; if 0<val<=0.5 then rnge='0~0.5'; else rnge='0.5~1'; > vnm='modi'; output; > run; > > proc tabulate data=have; > class type rnge vnm; > var val; > table type=''*rnge='',vnm=''*val=''*sum=''; > run; > > HTH > > Ya Hi, my trouble is I use a range columns(0~0.5,0.5~1) for original and modified data. If I define both columns by range in text, I will get 4x2 cells in my tabulate. ------------------------------------------------------------------------------------------------------ | Original_Range | Modified_Range | Original_Sum | Modified_Sum | ------------------------------------------------------------------------------------------------------ | | 0~0.5 | | | | 0~0.5 | --------------------------------------------------------------------------- | | 0.5~1 | | | ------------------------------------------------------------------------------------------------------- | | 0~0.5 | | | | 0.5~1 | --------------------------------------------------------------------------- | | 0.5~1 | | | ------------------------------------------------------------------------------------------------------- In Fact, I want: ----------------------------------------------------------------------------- | Range | Original_Sum | Modified_Sum | ---------------------------------------------------------------------------- | | | | | 0~0.5 | | | | | | | ---------------------------------------------------------------------------- | | | | | 0.5~1 | | | | | | | ----------------------------------------------------------------------------
From: Patrick on 10 Aug 2010 06:48 data have; infile datalines delimiter=' ' truncover; input Type:$1. original_data:8. modified_data:8.; datalines; A 0.32 0.45 B 0.62 0.70 ; run; data want(keep=type source value Cvalue); set have; source='original data'; value=original_data; Cvalue=value; output; source='modified data'; value=modified_data; Cvalue=value; output; run; proc format; value _range 0 - 0.5 = '0 - 0.5' 0.5 <- 1 = '>0.5 - 1' ; run; proc tabulate data=want; class source Cvalue; var value; format Cvalue _range.; table Cvalue=' ' ,source=' '*value=' '*sum=' ' /rts=15; run;
From: Ya on 10 Aug 2010 11:11 On Aug 10, 1:25 am, "litonc...(a)gmail.com" <litonc...(a)gmail.com> wrote: > On 8æ10æ¥, ä¸å11æ12å, Ya <huang8...(a)gmail.com> wrote: > > > > > > > On Aug 9, 6:44 pm, "litonc...(a)gmail.com" <litonc...(a)gmail.com> wrote: > > > > I have a problem about cross table. The following is a data example. > > > > Type($)  original_data(8.)   modified_data(8.) > > > A       0.32          0.45 > > > B       0.62          0.70 > > > ... > > > ... > > > > There are 3 columns, and original_data and modified_data are between > > > 0~1. I want to produce the following cross table. > > > > Type  Value  sum_of_original_data    Sum_of_modified_data > > > A    0~0.5 > > > A    0.5~1 > > > B    0~0.5 > > > B    0.5~1 > > > > How to produce the cross table?? > > > Try this: > > > data have; > >  set have; > > val=orig; if 0<val<=0.5 then rnge='0~0.5'; else rnge='0.5~1'; > > vnm='Orig'; output; > > val=modi; if 0<val<=0.5 then rnge='0~0.5'; else rnge='0.5~1'; > > vnm='modi'; output; > > run; > > > proc tabulate data=have; > > class type rnge vnm; > > var val; > > table type=''*rnge='',vnm=''*val=''*sum=''; > > run; > > > HTH > > > Ya > > Hi, my trouble is I use a range columns(0~0.5,0.5~1) for original and > modified data. If I define both columns by range in text, I will get > 4x2 cells in my tabulate. > ---------------------------------------------------------------------------Â--------------------------- > | Original_Range  |  Modified_Range | Original_Sum   | Modified_Sum | > ---------------------------------------------------------------------------Â--------------------------- > |             |     0~0.5 > |             |            | > |    0~0.5     | > --------------------------------------------------------------------------- > |             |     0.5~1 > |             |            | > ---------------------------------------------------------------------------Â---------------------------- > |             |     0~0.5 > |             |            | > |    0.5~1     | > --------------------------------------------------------------------------- > |             |     0.5~1 > |             |            | > ---------------------------------------------------------------------------Â---------------------------- > > In Fact, I want: > ---------------------------------------------------------------------------Â-- > |    Range     | Original_Sum   | Modified_Sum | > ---------------------------------------------------------------------------Â- > |             | > |            | > |    0~0.5      | > |            | > |             | > |            | > ---------------------------------------------------------------------------Â- > |             | > |            | > |    0.5~1      | > |            | > |             | > |            | > ---------------------------------------------------------------------------Â-- Hide quoted text - > > - Show quoted text - In that case, just drop the type: proc tabulate data=have; class /*type*/ rnge vnm; var val; table /*type=''*? rnge='',vnm=''*val=''*sum=''; run;
|
Pages: 1 Prev: How to get contional observation? Next: datetime informat |