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
SAS Super FREQ

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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