0

I have a SAS table that looks something like that:

  Mark  Country   Type  Count   Price

1 Mark1 Country1  type1   1     1.50 
2 Mark1 Country1  type2   5     21.00 
3 Mark1 Country1  type3   NA     NA 
4 Mark2 Country2  type1   2     197.50 
5 Mark2 Country2  type2   2     201.00 
6 Mark2 Country2  type3   1     312.50

I need to print two-dimentional statistics:

       Country1   Country2 
Type1    ...        ...  
Type2    ...        ...   
Type3    ...        ... 

where each sell looks like: price_max(count_sum)

Getting price_max in the cell is quite easy with proc tabulate

proc tabulate data=final_cars format=5.;
    class type country;
    var price count;
    table type, country*price*max; 
run;

But the question is how to put (count_sum) in each cell as well?

adeline
  • 21
  • 4
  • 2
    You can't. Tabulate cells are based on a single variable. Try `Proc REPORT`. See second answer in your earlier question https://stackoverflow.com/questions/64838455/reading-space-delimited-text-file-into-sas – Richard Nov 15 '20 at 15:13
  • @Richard thanks! But the problem is to merge price and count in proc report so that they were in one cell like "price_min(count_sum)". Is it possible in REPORT? Also I see that proc report gives sum report but not max. – adeline Nov 15 '20 at 17:16
  • 1
    Where ever there is a SUM stat in SAS be assured the panoply of stats ae also available. `REPORT` can compute a value when needed for special purposes – Richard Nov 15 '20 at 18:29
  • 1
    And sometimes you need to compute the multivalued aggregate cell separately and just `Proc PRINT` it. see your original q with updated a – Richard Nov 15 '20 at 18:42

1 Answers1

1

If I understand the question correctly, you can simply use PROC SQL:

proc sql;
  create table output as select distinct type,country,
  put(max(price),5.)||'('||put(sum(count),5.)||')' as price_count from have
  group by type,country
  order by type;
quit;

proc transpose data=output out=output1;
  by type;
  id country;
  var price_count;
run;

proc print data=output1(drop=_name_) noobs;
run;

enter image description here

crow16384
  • 587
  • 3
  • 15