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 !

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 4 replies
  • 1027 views
  • 1 like
  • 3 in conversation