BookmarkSubscribeRSS Feed
Mirou
Fluorite | Level 6
Hello,

i need to create this table using the sql procedure,

ccc.GIF

i try to work with the sql procedure, because i couldn't calculate the ratio sum(exp_prem)/sum(exposure) using the proc tabulate,
proc sql ;
create table ss2 as
select code,year
sum(exposure) as exposition,
sum(exp_prem)/sum(exposure)as premium,
group by code, year;
quit;

so i get this table as result,
Sans titre.png

What should i do,
Thank you

 

4 REPLIES 4
ballardw
Super User

@Mirou wrote:
Hello,

i need to create this table using the sql procedure,

ccc.GIF

i try to work with the sql procedure, because i couldn't calculate the ratio sum(exp_prem)/sum(exposure) using the proc tabulate,
proc sql ;
create table ss2 as
select code,year
sum(exposure) as exposition,
sum(exp_prem)/sum(exposure)as premium,
group by code, year;
quit;

so i get this table as result,
Sans titre.png

What should i do,
Thank you

 


Why does the report table need to be made by SQL? Either Proc Tabulate or Proc Report make such tables easy from your SS2 table.

Something like:

 

proc tabulate data=ss2;
   class code year;
   var exposition premium;
   table code='',
         (exposition premium)* year=''* max=''*f=best8.
         /box='Code' misstext=' '
   ;
run;

Proc Report could likely do the ratio needed but nested columns as shown might take more work in Report from the raw data.

Mirou
Fluorite | Level 6

thanks, but how could i insert this formula into the proc tabulate, "PremuimA =sum(premuin)/sum(exposition),"

 

LinusH
Tourmaline | Level 20

Then you need PROC REPORT, using COMPUTE block.

Or if you can have it pre-calculated on detail level first (using SQL), then TABULATE.

Data never sleeps
Mirou
Fluorite | Level 6

thank you !

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 4 replies
  • 1640 views
  • 1 like
  • 3 in conversation