tags:

views:

18

answers:

1

Is it usual that the Univariate Frequencies does not display the BY-variable while Univariate BasicMeasures does show the BY-variable?

In the example below I load in some data and want to show gas prices by zipcode. The output for PROC FREQ shows the BY-variable (zipcode) in the output as does the UNIVARIATE BasicMeasures. But the UNIVARIATE Frequencies is not showing the BY-variable in the output.

Am I doing something wrong? I've even set the templates to default, with the ODS PATH statement, in case the templates got messed up by other code (or other coders using same account).

DATA prices;
  INPUT  zipcode price;
  DATALINES;
90066 3.10
90066 3.17
90066 3.26
98101 2.99
98101 3.06
98101 3.16
;
run;
proc sort;
  by zipcode;
run;

ods path sashelp.tmplmst(read) ;

ods pdf file = "gasprices.pdf";
PROC FREQ data = prices;
  tables price;
  by zipcode;
run;    
ods select Frequencies;
PROC UNIVARIATE data = prices freq;
  var price;
  by zipcode;
run;
ods select BasicMeasures;
PROC UNIVARIATE data = prices;
  var price;
  by zipcode;
run;
ods pdf close;
A: 

You can specify more than one object in the ODS SELECT, so you could pull both tables out of the same PROC FREQ like this:

ods pdf file = "gasprices.pdf"; 
ods select BasicMeasures Frequencies; 
PROC UNIVARIATE data = prices freq; 
  var price; 
  by zipcode; 
run; 
ods pdf close; 

I know that doesn't exactly solve your problem, but it looks to me like the BY-variable display just isn't properly linked to the PROC UNIVARIATE frequency tables (e.g., try ODS SELECT Moments - works fine). Might be worth reporting to SAS.

Matt Parker
Cool, that's a good solution. Many thanks for the idea. Better than my inefficient alternate approach of splitting up data and manually filling in titles.
George Tbrain