Desktop productivity for business analysts and programmers

MONYY7 in Summary Statistics not working?

Reply
Occasional Contributor
Posts: 9

MONYY7 in Summary Statistics not working?

I am applying the MONYY7. format to a date field in the Summary Statistics dialog. However, it always appears in the output as MONYY5.??

It works fine in One Way Frequencies, and in other dialogs.

The code preview clearly shows the line FORMAT MYDATE MONYY7.

Any help is appreciated.
SAS Super FREQ
Posts: 8,818

Re: MONYY7 in Summary Statistics not working?

Hi:
You are probably using the DATE variable in a CLASS statement (or else you're selecting it as the classification variable) in your task. I can duplicate your issue with code.
[pre]
data testdate;
set sashelp.prdsale;
** month IS a SAS date, but formatted to MonName3;
** so create an explicit date variable and a character date variable;
date = month;
altdate = date;
chardate = put(month,monyy7.);
format date monyy7. altdate date9.;
run;

proc print data=testdate(obs=15);
var prodtype date altdate chardate actual;
title 'proc print using formats assigned in data step';
run;

ods listing;
proc means data=testdate;
title 'compare date formats used to proc print of data';
var actual;
class date altdate;
format date monyy7. altdate date9.;
run;

proc means data=testdate;
title 'using character version of date';
var actual;
class chardate;
run;

[/pre]

But duplicating the problem doesn't really help you. The workaround that I show in my code is to create a character variable that contains the date formatted with MONYY7 and then use the character variable as the CLASS variable in your summary statistics task. Or just switch over to a code node and submit the proc means code once you create the character version of the date.

However, I think your best bet for help with this problem is to contact Tech Support. There's something odd happening and Tech Support is the best place to go for help.

To find out how to contact Tech Support, refer to:
http://support.sas.com/techsup/contact/index.html

cynthia
Frequent Contributor
Posts: 91

Re: MONYY7 in Summary Statistics not working?

Cynthia, if you substitute proc summary with an output statement for your proc means, the class variables "respect" the formats that have been assigned. Of course, then you would need a proc print to display the results.


proc summary data=testdate nway missing;
title 'compare date formats used to proc print of data';
var actual;
class date altdate;
format date monyy7. altdate date9.;
output out=testdate1;
run;
Occasional Contributor
Posts: 9

Re: MONYY7 in Summary Statistics not working?

I guess I need to report this as a bug. I'm assisting end users who are not code savvy, so I want to limit the use of code as much as possible.
SAS Super FREQ
Posts: 8,818

Re: MONYY7 in Summary Statistics not working?

Hi:
I see that. It was my understanding that PROC MEANS and PROC SUMMARY were using the SAME code and the only difference was the print/noprint settings.

IF you take the output statement away from the PROC SUMMARY, then you do get the same behavior as when you use PROC MEANS:
[pre]
proc summary data=testdate print;
var actual;
class date altdate;
format date monyy7. altdate date9.;
*******output out=testdate1;
run;

[/pre]

In fact, if you put the OUTPUT statement in PROC MEANS, then you get the same results as the PROC SUMMARY with an OUTPUT
statement. I think the behavior in either case (ignoring the MONYY format) is incorrect.

So I still think that the workaround is:
1) convert the date to a character string for the CLASS variable
2) always use the OUTPUT statement with either PROC MEANS or PROC SUMMARY and then always follow it with a PROC PRINT.

But there's still the issue of "is this working as designed -- why would you NOT want to respect the format on the CLASS variable, even if the CLASS variable is numeric" -- and that's a question for Tech Support.

cynthia
Ask a Question
Discussion stats
  • 4 replies
  • 460 views
  • 0 likes
  • 3 in conversation