Date: Fri, 6 Apr 2001 11:07:06 -0400
Reply-To: Ian Whitlock <WHITLOI1@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ian Whitlock <WHITLOI1@WESTAT.COM>
Subject: Re: Tabulate query
Content-Type: text/plain; charset="iso-8859-1"
Chris,
Ok, it is your problem and you say it doesn't work, but here is my log and
results with the top LH cell showing a count of zero because there is no
data for that cell.
277 data temp;
278 Attrib s informat=$char2. month informat=monyy7. format=monyy7.
279 date informat=ddmmyy8. format=monyy7. ;
280 input s month date;
281 list ;
282 cards;
RULE:----+----1----+----2----+----3----+----4----+----5----+----6----+----7-
---+----8----+----9-
283 a2 Jun2001 10/6/2001
284 a2 Jul2001 3/7/2001
285 a2 Jun2001 1/6/2001
286 a1 Jul2001 9/7/2001
NOTE: The data set WORK.TEMP has 4 observations and 3 variables.
NOTE: DATA statement used:
real time 0.04 seconds
287 ;
288 run;
289
290 Proc Tabulate Data=temp order=internal Format=7.0;
291 Class s date month ;
292 Table s, N=' '*date="month" /MISSTEXT='0';
293 Table s, N=' '*month /MISSTEXT='0';
294 Run;
The SAS System 08:39
Friday, April 6, 2001 15
----------------------------------------
| | month |
| |---------------|
| |JUN2001|JUL2001|
|----------------------+-------+-------|
|s | | |
|----------------------| | |
|a1 | 0| 1|
|----------------------+-------+-------|
|a2 | 2| 1|
----------------------------------------
The SAS System 08:39
Friday, April 6, 2001 16
----------------------------------------
| | month |
| |---------------|
| |JUN2001|JUL2001|
|----------------------+-------+-------|
|s | | |
|----------------------| | |
|a1 | 0| 1|
|----------------------+-------+-------|
|a2 | 2| 1|
----------------------------------------
Ian Whitlock <whitloi1@westat.com>
-----Original Message-----
From: Chris Wooff [mailto:C.Wooff@liverpool.ac.uk]
Sent: Friday, April 06, 2001 10:38 AM
To: Ian Whitlock
Cc: SAS(r) Discussion
Subject: Re: Tabulate query
Ian, changing the properties on "month" doesn't make any difference - the
crucial thing is that there is no data for what needs to be the top LH
"cell" of tabulate. Fortunately the solution of using 2 seperate class
statements does work.
--On 06 April 2001 09:52 -0400 Ian Whitlock <whitloi1@WESTAT.COM> wrote:
> Peter,
>
> Thanks for the reminder about order on separate class statements.
> With the correct sort order for this example it works. But I think
> the real problem here is the failure to treat MONTH as a SAS date.
> With
>
> data temp;
> Attrib s informat=$char2. month informat=monyy7. format=monyy7.
> date informat=ddmmyy8. format=date9. ;
> input s month :monyy7. date;
> cards;
> a2 Jun2001 10/6/2001
> a2 Jul2001 3/7/2001
> a2 Jun2001 1/6/2001
> a1 Jul2001 9/7/2001
> ;
> run;
>
> the TABULATE code runs fine when ORDER=INTERNAL. Now no sort is
> needed. Of course, if DATE had the MONNY7. format then the TABULATE
> code could have been
>
> Proc Tabulate Data=temp order=internal Format=7.0;
> Class s date ;
> Table s, N=' '*date="month" /MISSTEXT='0';
> Run;
>
> and we are rid of one unneeded variable as well as the sort.
>
> In general in SAS one should expect problems or complexity with
> arithmetic or order involving dates if one refuses to use SAS dates
> with formats.
>
> Ian Whitlock <whitloi1@westat.com>
>
> On Fri, 6 Apr 2001 12:23:40 +0100, Peter Crawford
> <peter.crawford@DB.COM> wrote:
>
>> in v8 Tabulate allows the order= option to be specified as a class
> statement option,
>> and allows there to be more than one class statement. With these
> alternative facilities
>> use different ORDER= options
>> proc sort data=temp;
>> by date;
>> run;
>>
>> Proc Tabulate Data=temp Format=7.0;
>> Class s / order=internal;
>> Class month / order=data ;
>> Table s, N=' '*month /MISSTEXT='0';
>> Run;
>>
>>
>>
>> Datum: 06/04/2001 10:52
>> An: SAS-L@listserv.uga.edu
>>
>>
>>
>>
>> Antwort an: Chris Wooff <C.Wooff@LIVERPOOL.AC.UK>
>>
>> Betreff: Tabulate query
>> Nachrichtentext:
>>
>> I'm having a problem in getting results sorted correctly when using
>> tabulate. Code fragment is best summarised as follows:
>>
>> data temp;
>> Attrib s informat=$char2. month informat=$char7.
>> date informat=ddmmyy8.;
>> input s month date;
>> cards;
>> a2 Jun2001 10/6/2001
>> a2 Jul2001 3/7/2001
>> a2 Jun2001 1/6/2001
>> a1 Jul2001 9/7/2001
>> ;
>> run;
>>
>> proc sort data=temp;
>> by s date;
>> run;
>>
>> Proc Tabulate Data=temp order=data Format=7.0;
>> Class s month;
>> Table s, N=' '*month /MISSTEXT='0';
>> Run;
>>
>>
>> Because there are no entries corresponding to s=a1 and month=Jun2001
>> the result is:
>>
>> -------------------------------------------------
>> ====== | | month |
>> ====== | |---------------|
>> ====== | |Jul2001|Jun2001|
>> ====== |-------------------------------+-------+-------|
>> ====== |s | | |
>> ====== |-------------------------------| | |
>> ====== |a1 | 1| 0|
>> ====== |-------------------------------+-------+-------|
>> ====== |a2 | 1| 2|
>> ====== -------------------------------------------------
>>
>> Can anyone think of a neat solution to get the column headings to
>> appear in chronological order? (NB changing the sort order to "date
>> s" is not an option because the row headings then appear in the wrong
>> order). I thought of creating a dataset of 0s and merging it with the
>> data. However, this will be quite tricky in the real code and I'd
>> prefer something tidier.
>>
>>
>>
>> __________________________________________
>> Chris Wooff mailto:C.Wooff@liverpool.ac.uk
>> Sent with Mulberry 2.1.0a4
>>
>>
>>
>>
>>
>> --
>>
>> Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte
> Informationen. Wenn Sie nicht der richtige Adressat sind oder diese
> E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den
> Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie
> die unbefugte Weitergabe dieser Mail ist nicht gestattet.
>>
>> This e-mail may contain confidential and/or privileged information.
>> If you
> are not the intended recipient (or have received this e-mail in error)
> please notify the sender immediately and destroy this e-mail. Any
> unauthorised copying, disclosure or distribution of the material in
> this e- mail is strictly forbidden.
__________________________________________
Chris Wooff mailto:C.Wooff@liverpool.ac.uk
Sent with Mulberry 2.1.0a4