BookmarkSubscribeRSS Feed
jcis7
Pyrite | Level 9

Name County Total   Type      Year      Med        Bel     

site1     A          34         1     2000       2             3                      

site2     C          12         2      2000       2            2

site3     C          44         1      2000       2            2          

site4     A          25         1      2002       3            2   

site5     B          23         2      2002       0            2  

site6     C          13         1     2002        1            3

Output:

                                                                                Type1                                         Type2

           Total        Med     PctMed       Bel   PctBel        Total   Med    PctMed    Bel        Total     Med   PctMed   Bel   PctBel                        

2000     90          6              6.6          7       7.7             78        4        5.1         etc...

2002     61          4              6.5          7       11.4            48       4        8.3          etc...

  

I tried this but it doesn't work. Any help you can give will be much appreciated!

ods html file = 'C:\MyDocuments\procreport_pct.html';

proc report data=want nowd;

title 'Report';

     COLUMN  year total  med bel, type;

     DEFINE year / group;

     DEFINE total / sum;

     DEFINE med /  sum;

     DEFINE med_pct / COMPUTED FORMAT = percent8.2;

     DEFINE  bel / sum;

     DEFINE bel_pct / COMPUTED FORMAT = percent8.2;

     rbreak after / summarize;

run;

3 REPLIES 3
allurai0412
Fluorite | Level 6

hi,

try with proc tabualate...but not sure if it works...

You should change the table cloulmns...

PROC TABULATE DATA=HAVE;

VAR TOTAL MED BEL ;

TABLE YEAR  , (TYPE) *(TOTAL*(N PCTN) MED*PCTN);

CLASS  YEAR TYPE ;

RUN;

Regards

ALLU

jcis7
Pyrite | Level 9

Thanks!

Cynthia_sas
Diamond | Level 26

Hi,

  I'm confused. I don't see how the PROC REPORT code that you show can produce the output that you posted. For one thing, you only cross or nest BEL with TYPE, but in your output, it looks like you have med med_pct bel and bel_pct under each type, so I would have expected a COLUMN statement like:

COLUMN  year total  type,( med med_pct bel bel_pct);

  But, maybe you also have TOTAL under each TYPE. It's hard to say.

  And then, you DEFINE both med_pct and bel_pct as COMPUTED usage, but you don't show the COMPUTE blocks. So I'm not sure how you're getting numbers for med_pct or bel_pct.

  Did you run code to get the output you posted? Or is the output you posted a mock-up of what you hope to get?

  To do this kind of report, you will have to investigate using Absolute column numbers for calculating percents in the COMPUTE block, you will have to figure out what you want in the column statement first, because the order of the variables in the column statement will impact the absolute column numbers.

  Or, you might want to try this with TABULATE, as previously suggested.

cynthia

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1156 views
  • 0 likes
  • 3 in conversation