DATA Step, Macro, Functions and more

Someone please help me out in writting a macro statements for this!

Reply
Frequent Contributor
Posts: 78

Someone please help me out in writting a macro statements for this!

I found myself repeating the below datastep five times. I know %macro can help me to save the effort of writting the script over and over again. However, I am unsure on how to use it. =/ Hoping someone can help me out!

Proc Summary Data = GIO_VOR Nway Missing;
Class month GioBike_Grp;
Var claimCount epy earnedPrem incurToDate;
Output out = Gccgrp (Drop = _Type_ _Freq_) Sum=;
Run;

Data Gccgrp;
Set Gccgrp;
Length Claims_Frequency 8. Loss_Ratio 8.;
Claims_Frequency = (claimCount/EPY) * 100;
Loss_Ratio = (incurToDate/earnedPrem) * 100;
Run;

Proc Summary Data = GIO_VOR Nway Missing;
Class month GioCover_Type;
Var claimCount epy earnedPrem incurToDate;
Output out = Gcover (Drop = _Type_ _Freq_) Sum=;
Run;

Data Gcover;
Set Gcover;
Length Claims_Frequency 8. Loss_Ratio 8.;
Claims_Frequency = (claimCount/EPY) * 100;
Loss_Ratio = (incurToDate/earnedPrem) * 100;
Run;

Proc Summary Data = GIO_VOR Nway Missing;
Class month GIO_Ageband;
Var claimCount epy earnedPrem incurToDate;
Output out = GAgeband (Drop = _Type_ _Freq_) Sum=;
Run;

Data Gageband;
Set GAgeband;
Length Claims_Frequency 8. Loss_Ratio 8.;
Claims_Frequency = (claimCount/EPY) * 100;
Loss_Ratio = (incurToDate/earnedPrem) * 100;
Run;

Proc Summary Data = GIO_VOR Nway Missing;
Class month GioChannel_Grp;
Var claimCount epy earnedPrem incurToDate;
Output out = Gchannel (Drop = _Type_ _Freq_) Sum=;
Run;

Data Gchannel;
Set Gchannel;
Length Claims_Frequency 8. Loss_Ratio 8.;
Claims_Frequency = (claimCount/EPY) * 100;
Loss_Ratio = (incurToDate/earnedPrem) * 100;
Run;

Proc Summary Data = GIO_VOR Nway Missing;
Class month GioBike_Make;
Var claimCount epy earnedPrem incurToDate;
Output out = Gbikemake (Drop = _Type_ _Freq_) Sum=;
Run;

Data Gbikemake;
Set Gbikemake;
Length Claims_Frequency 8. Loss_Ratio 8.;
Claims_Frequency = (claimCount/EPY) * 100;
Loss_Ratio = (incurToDate/earnedPrem) * 100;
Run;

Much Appreciated.

Yennie
SAS Super FREQ
Posts: 8,864

Re: Someone please help me out in writting a macro statements for this!

Hi:
Reading the macro documentation will probably help you. Consulting any of Art Carpenter or Michele Burlew's macro books will probably help you. Searching for User Group papers (like this one) will probably help you:
http://www2.sas.com/proceedings/sugi28/056-28.pdf

The SAS Macro Facility is a big topic and the best thing to do is to start with a working SAS program (which it looks like you have) and then slowly experiment with "macro-tizing" the program...as described in the 9 steps in the above paper.

cynthia
Frequent Contributor
Posts: 78

Re: Someone please help me out in writting a macro statements for this!

Posted in reply to Cynthia_sas
Hey cynthia!

This is awesome. Thank you!


Cheers
Yennie
Ask a Question
Discussion stats
  • 2 replies
  • 115 views
  • 0 likes
  • 2 in conversation