SlideShare a Scribd company logo
1 of 16
Formats
Patrick Cuba – Consultant
(SAS® Software)
how to use them
and
Page 1
• Three main categories of SAS Formats
• Informats & Formats
• Conversion
• User Defined Formats
• Picture Formats
• Lookup tables
• Business example using Formats from lookup tables
• References
Page 2
“Hello Bill”THREE CATEGORIES
TEXT $ $20.
$UPCASEw.
“HELLO BILL”
$REVERSw
“lliB olleH”
$HEXw. “48656C6C6F2042696C6C”
NUMERIC 11.2611.2 25.50
DOLLAR10.2 $25.50
DATE & TIME DATE9. 25FEB2014
yymmdd10. 2014-02-25
yymmddp10. 2014.02.25
time8. 16:45:24
datetime21.2 25FEB2014:16:45:24.00
11. 19779
Z7. 0019779
Page 3
Infile Filename
Input Fee_ID : $10.
Asat_Date : YYMMDD10.
Desc : $20.
Fee_Amt : Dollar.2
1,2014/01/01,Admin Fee,$3.50
1,2014/03/01,Admin Fee,$4.00
1,2014/05/01,Admin Fee,$5.25
Format Date yymmdd10. Date=2014-05-16
Date=date(); Date=19859
File textSAS Data step code
DisplaySAS Datastep code
Page 4
Val1=1
NUM to CHAR
Put(<num>, numeric-format)
CHAR to NUM
Input(<char>, character-format)
Val2=1-Text
Val3=1000 Val4=1000
Val5=.
Data _null_;
Length Val1 Val4 8. Val2 Val3 $10.;
Val1=1;
Val2=Compress(put(Val1, 8. -L)||'-Text');
Val3='1000';
Val4=input(Val3, $10.);
Val5=input(Val2, ??8.);
Put Val1= Val2= Val3= Val4= Val5=;
Run;
Page 5
Proc Format;
Picture ToRand low-high='000,000' (Prefix='R' Mult=9.52);
Picture ToDollar low-high='000,000' (Prefix='$' Mult=0.10);
Quit;
Data _null_;
AUD=10;
ZAR=Put(AUD, ToRand.);
Beer=10;
BeerinOz=Put(Beer, ToDollar.);
Put AUD=Dollar10. ZAR=;
Put BeerinOz=;
Run;
AUD=$10 ZAR=R95 BeerinOz=$1
Page 6
PROC FORMAT;
Value $SEX 'M'='Male'
'F'='Female'
Other='Unknown';
Quit;
CodeN=Male
CodeT=Male
Score=C
Data _null_;
CodeN=Put(1, Sex.);
CodeT=Put('M', $Sex.);
Score=Put('M', $Score.);
Put CodeN= CodeT= Score=;
Run;
SAS PROC FORMAT SAS Data Step
Output
$FMTNAME Character
FMTNAME Numeric
PROC FORMAT;
Value $SEX 'M'='Male'
'F'='Female'
Other='Unknown';
Value SEX 1='Male'
2='Female'
Other='Unknown';
Quit;
PROC FORMAT;
Value $SEX 'M'='Male'
'F'='Female'
Other='Unknown';
Value SEX 1='Male'
2='Female'
Other='Unknown';
Value $Score 'a'-<'e','A'-<'E'='A'
'e'-<'m','E'-<'M'='B'
'm'-'z~','M'-'Z~'='C';
Quit;
Range
Page 7
PROC FORMAT CNTLIN=Lookup Table
Start
End <optional>
HLO <optional>
Type <optional>
PROC FORMAT CNTLOUT=Lookup Table
Label
FmtName
Activity_ID Activity Description Fee
1 Letter $8.50
2 Phone - Call $9.00
3 Phone - Receive $5.00
4 Account Open $5.00
5 Account Close $3.00
Data Lookup
Start Label FMTNAME
1 $8.50 ACT.
2 $9.00 ACT.
3 $5.00 ACT.
4 $5.00 ACT.
5 $3.00 ACT.
Page 8
1 x AccountAccount
Activity
n x Activities
Debt Collection
1. Open Account
2. Call Debtor
3.Send letter to
Debtor
4. Debtor calls
debtee
5. Close Account
Activities
Fee n x Fees
Fees
Stamps
Disbursement
Admin
Legal
Postage
Page 9
Account
Activities
Activity
Fee
Accno Activity_ID Date
ACC00012345 4 5/01/2014
ACC00012345 1 6/01/2014
ACC00012345 3 10/01/2014
ACC00012345 2 11/01/2014
ACC00012345 5 11/01/2014
ACC00012346 4 5/01/2014
ACC00012346 1 6/01/2014
ACC00012346 3 15/01/2014
ACC00012346 2 15/01/2014
ACC00012346 3 25/01/2014
Fee_ID Fee_asatdate Fee Description Fee_Amount
1 1/01/2014 Admin Fee $3.50
1 1/03/2014 Admin Fee $4
1 1/05/2014 Admin Fee $5.25
2 1/01/2014 Disbursements $1
2 1/04/2014 Disbursements $1.25
3 1/01/2014 Legal Fee $0.50
3 6/04/2014 Legal Fee $1
3 1/06/2014 Legal Fee $0.75
6 1/01/2014 Stamps $1.50
6 5/04/2014 Stamps $1.75
6 1/05/2014 Stamps $2
7 1/01/2014 Postage $2
7 18/05/2014 Postage $2.15
Activity_ID Activity
Description
Fee_ID
1 Letter 1
1 Letter 2
1 Letter 3
1 Letter 6
1 Letter 7
Activity
Fee
Account
Activities
Page 10
Format $ACTFEE
Activity_ID Activity Description Fee_ID
1 Letter 1
1 Letter 2
1 Letter 3
1 Letter 6
1 Letter 7
2 Phone - Call 1
2 Phone - Call 2
2 Phone - Call 3
2 Phone - Call 9
3 Phone - Receive 1
3 Phone - Receive 2
3 Phone - Receive 3
4 Account Open 4
5 Account Close 5
Lookup
Start: Activity_ID-
Fee_ID
Label
A001-001 A001-002
A001-002 A001-003
A001-003 A001-006
A001-006 A001-007
A001-007 Activity-End
A002-001 A002-002
A002-002 A002-003
A002-003 A002-009
A002-009 Activity-End
A003-001 A003-002
A003-002 A003-003
A003-003 Activity-End
A004-004 Activity-End
A005-005 Activity-End
Cat("A",Put(Activity_ID,Z3.),"-",Put(Fee_ID,z3.));
Page 11
Fee_ID Fee_asatdate Fee Description Fee_Amount
1 1/01/2014 Admin Fee $3.50
1 1/03/2014 Admin Fee $4
1 1/05/2014 Admin Fee $5.25
2 1/01/2014 Disbursements $1
2 1/04/2014 Disbursements $1.25
3 1/01/2014 Legal Fee $0.50
3 6/04/2014 Legal Fee $1
3 1/06/2014 Legal Fee $0.75
6 1/01/2014 Stamps $1.50
6 5/04/2014 Stamps $1.75
6 1/05/2014 Stamps $2
7 1/01/2014 Postage $2
7 18/05/2014 Postage $2.15
Format $FEELookup
Start: Fee_ID-StartDate End: Fee_ID-EndDate Label
001-0041640 001-0041698 $3.50
001-0041699 001-0041759 $4.00
001-0041760 001-High-Date $5.25
002-0041640 002-0041729 $1.00
002-0041730 002-High-Date $1.25
003-0041640 003-0041734 $0.50
003-0041735 003-0041790 $1.00
003-0041791 003-High-Date $0.75
006-0041640 006-0041733 $1.50
006-0041734 006-0041759 $1.75
006-0041760 006-High-Date $2.00
007-0041640 007-0041776 $2.00
007-0041777 007-High-Date $2.15
Cat(Put(Fee_ID*1, Z3.), "-",
Put(Start_Date,Z7.))
Cat(Put(Fee_ID*1, Z3.), "-",
Put(End_Date,Z7.))
Fee_ID Start_Date End_Date Fee_Amt
1 2014-01-01 2014-02-28 $4.00
1 2014-03-01 2014-04-30 $5.25
1 2014-05-01 9999-12-31 $5.25
2 2014-01-01 2014-03-31 $1.25
2 2014-04-01 9999-12-31 $1.25
3 2014-01-01 2014-04-05 $1.00
3 2014-04-06 2014-05-31 $0.75
3 2014-06-01 9999-12-31 $0.75
4 2014-01-01 9999-12-31 $5.00
5 2014-01-01 9999-12-31 $3.00
6 2014-01-01 2014-04-04 $1.75
6 2014-04-05 2014-04-30 $2.00
6 2014-05-01 9999-12-31 $2.00
7 2014-01-01 2014-05-17 $2.15
7 2014-05-18 9999-12-31 $2.15
Page 12
Account
Activities
Accno Activity_ID Date Fee Total
ACC00012345 4 5/01/2014 $5.00
ACC00012345 1 6/01/2014 $8.50
ACC00012345 3 10/01/2014 $5.00
ACC00012345 2 11/01/2014 $9.00
ACC00012345 5 11/01/2014 $3.00
ACC00012346 4 5/01/2014 $5.00
ACC00012346 1 6/01/2014 $8.50
ACC00012346 3 15/01/2014 $5.00
ACC00012346 2 15/01/2014 $9.00
ACC00012346 3 25/01/2014 $5.00
ACC00012346 1 31/03/2014 $9.00
50c admin fee increase
applied on 1/3/2014
Fee_ID Fee_asatdate Fee Description Fee_Amount
1 1/01/2014 Admin Fee $3.50
2 1/01/2014 Disbursements $1
3 1/01/2014 Legal Fee $0.50
6 1/01/2014 Stamps $1.50
7 1/01/2014 Postage $2
Fee_ID Fee_asatdate Fee Description Fee_Amount
1 1/03/2014 Admin Fee $4
2 1/01/2014 Disbursements $1
3 1/01/2014 Legal Fee $0.50
6 1/01/2014 Stamps $1.50
7 1/01/2014 Postage $2
Applicable Fees
Accno Activity_ID Date Fee Total
ACC00012345 4 5/01/2014 $5.00
ACC00012345 1 6/01/2014 $8.50
ACC00012345 3 10/01/2014 $5.00
ACC00012345 2 11/01/2014 $9.00
ACC00012345 5 11/01/2014 $3.00
ACC00012346 4 5/01/2014 $5.00
ACC00012346 1 6/01/2014 $8.50
ACC00012346 3 15/01/2014 $5.00
ACC00012346 2 15/01/2014 $9.00
ACC00012346 3 25/01/2014 $5.00
ACC00012346 1 31/03/2014 $9.00
Page 13
Do Until(Put(Fee_total, $ACTFEE.)='Activity-End');
*** 1. Loop for each activity *** ;
Iter+1;
If Iter=1 then Fee_total=Put(Cat("A",Put(Activity_ID, z3.)), $ACTFEE.);
Else Fee_total=Put(Fee_total, $ACTFEE.);
*** 2. Apply correct fee per actiovity for the date *** ;
FeePrt=Cat(Strip(Scan(Fee_total,-1,'-')),"-",Put(Asat_Date, z7.));
FeeAmt=Put(FeePrt, $Fee.);
Fees=Sum(Fees, FeeAmt);
Output;  Add this line if you want to test the breakdown of fees charged
End;
Account
Activities
Page 14
SAS Formats
https://support.sas.com/documentation/cdl/en/leforinforref/64790/HTML/defa
ult/viewer.htm#titlepage.htm
Sample Code & Test Data
<to be determined>
Base SAS Procedure guide
https://support.sas.com/documentation/cdl/en/proc/66663/HTML/default/vie
wer.htm
Page 15
Email: patrickcuba8@gmail.com
Mobile: 0458 91 2634
Linkedin: http://www.linkedin.com/in/patrickcuba
Page 16

More Related Content

Similar to Fee Formats v1 no animation

Technological Solutions
Technological SolutionsTechnological Solutions
Technological Solutions
Alex Luna
 
Technological Solutions
Technological SolutionsTechnological Solutions
Technological Solutions
Alex Luna
 
Afternoon Sessions
Afternoon SessionsAfternoon Sessions
Afternoon Sessions
gmm0611
 
All-In AdWords Strategies for Peak Season
All-In AdWords Strategies for Peak SeasonAll-In AdWords Strategies for Peak Season
All-In AdWords Strategies for Peak Season
ROI Revolution
 
Creating a budget that makes cents
Creating a budget that makes centsCreating a budget that makes cents
Creating a budget that makes cents
Sara Capetillo
 
Park Power Opportunity Presentation
Park Power Opportunity PresentationPark Power Opportunity Presentation
Park Power Opportunity Presentation
Park Power
 
How to write business plan for e commerce.pptx
How to write business plan for e commerce.pptxHow to write business plan for e commerce.pptx
How to write business plan for e commerce.pptx
Mugabo4
 
Consolidated Portfolio Comp 06.11.15
Consolidated Portfolio Comp 06.11.15Consolidated Portfolio Comp 06.11.15
Consolidated Portfolio Comp 06.11.15
Michael Beare
 
Reporte de predial 2014%2c 2015 y lo que va del 2016
Reporte de predial 2014%2c 2015 y lo que va del 2016Reporte de predial 2014%2c 2015 y lo que va del 2016
Reporte de predial 2014%2c 2015 y lo que va del 2016
gigi187
 
Multichannel fundraising how dom does it - aci presentation 2013 for slides...
Multichannel fundraising   how dom does it - aci presentation 2013 for slides...Multichannel fundraising   how dom does it - aci presentation 2013 for slides...
Multichannel fundraising how dom does it - aci presentation 2013 for slides...
Amy Kaczmarek
 

Similar to Fee Formats v1 no animation (20)

construction report sample 5.5.15
construction report sample 5.5.15construction report sample 5.5.15
construction report sample 5.5.15
 
PSEG TCS SAP Collections Management
PSEG TCS SAP Collections ManagementPSEG TCS SAP Collections Management
PSEG TCS SAP Collections Management
 
Technological Solutions
Technological SolutionsTechnological Solutions
Technological Solutions
 
Technological Solutions
Technological SolutionsTechnological Solutions
Technological Solutions
 
Afternoon Sessions
Afternoon SessionsAfternoon Sessions
Afternoon Sessions
 
Business Plan
Business PlanBusiness Plan
Business Plan
 
All-In AdWords Strategies for Peak Season
All-In AdWords Strategies for Peak SeasonAll-In AdWords Strategies for Peak Season
All-In AdWords Strategies for Peak Season
 
2015 Employer Tax Information and Workers' Comp Rates
2015 Employer Tax Information and Workers' Comp Rates2015 Employer Tax Information and Workers' Comp Rates
2015 Employer Tax Information and Workers' Comp Rates
 
Creating a budget that makes cents
Creating a budget that makes centsCreating a budget that makes cents
Creating a budget that makes cents
 
Park Power Opportunity Presentation
Park Power Opportunity PresentationPark Power Opportunity Presentation
Park Power Opportunity Presentation
 
How to write business plan for e commerce.pptx
How to write business plan for e commerce.pptxHow to write business plan for e commerce.pptx
How to write business plan for e commerce.pptx
 
Company Orientation Process Powerpoint Presentation Slides
Company Orientation Process Powerpoint Presentation SlidesCompany Orientation Process Powerpoint Presentation Slides
Company Orientation Process Powerpoint Presentation Slides
 
Company Orientation Process PowerPoint Presentation Slides
Company Orientation Process PowerPoint Presentation Slides Company Orientation Process PowerPoint Presentation Slides
Company Orientation Process PowerPoint Presentation Slides
 
Consolidated Portfolio Comp 06.11.15
Consolidated Portfolio Comp 06.11.15Consolidated Portfolio Comp 06.11.15
Consolidated Portfolio Comp 06.11.15
 
Reporte de predial 2014%2c 2015 y lo que va del 2016
Reporte de predial 2014%2c 2015 y lo que va del 2016Reporte de predial 2014%2c 2015 y lo que va del 2016
Reporte de predial 2014%2c 2015 y lo que va del 2016
 
Multichannel fundraising how dom does it - aci presentation 2013 for slides...
Multichannel fundraising   how dom does it - aci presentation 2013 for slides...Multichannel fundraising   how dom does it - aci presentation 2013 for slides...
Multichannel fundraising how dom does it - aci presentation 2013 for slides...
 
As of June 30, 2017
As of June 30, 2017As of June 30, 2017
As of June 30, 2017
 
TeamSixBP
TeamSixBPTeamSixBP
TeamSixBP
 
Business Plan - Term Project
Business Plan - Term ProjectBusiness Plan - Term Project
Business Plan - Term Project
 
Managersreport
ManagersreportManagersreport
Managersreport
 

Fee Formats v1 no animation

  • 1. Formats Patrick Cuba – Consultant (SAS® Software) how to use them and Page 1
  • 2. • Three main categories of SAS Formats • Informats & Formats • Conversion • User Defined Formats • Picture Formats • Lookup tables • Business example using Formats from lookup tables • References Page 2
  • 3. “Hello Bill”THREE CATEGORIES TEXT $ $20. $UPCASEw. “HELLO BILL” $REVERSw “lliB olleH” $HEXw. “48656C6C6F2042696C6C” NUMERIC 11.2611.2 25.50 DOLLAR10.2 $25.50 DATE & TIME DATE9. 25FEB2014 yymmdd10. 2014-02-25 yymmddp10. 2014.02.25 time8. 16:45:24 datetime21.2 25FEB2014:16:45:24.00 11. 19779 Z7. 0019779 Page 3
  • 4. Infile Filename Input Fee_ID : $10. Asat_Date : YYMMDD10. Desc : $20. Fee_Amt : Dollar.2 1,2014/01/01,Admin Fee,$3.50 1,2014/03/01,Admin Fee,$4.00 1,2014/05/01,Admin Fee,$5.25 Format Date yymmdd10. Date=2014-05-16 Date=date(); Date=19859 File textSAS Data step code DisplaySAS Datastep code Page 4
  • 5. Val1=1 NUM to CHAR Put(<num>, numeric-format) CHAR to NUM Input(<char>, character-format) Val2=1-Text Val3=1000 Val4=1000 Val5=. Data _null_; Length Val1 Val4 8. Val2 Val3 $10.; Val1=1; Val2=Compress(put(Val1, 8. -L)||'-Text'); Val3='1000'; Val4=input(Val3, $10.); Val5=input(Val2, ??8.); Put Val1= Val2= Val3= Val4= Val5=; Run; Page 5
  • 6. Proc Format; Picture ToRand low-high='000,000' (Prefix='R' Mult=9.52); Picture ToDollar low-high='000,000' (Prefix='$' Mult=0.10); Quit; Data _null_; AUD=10; ZAR=Put(AUD, ToRand.); Beer=10; BeerinOz=Put(Beer, ToDollar.); Put AUD=Dollar10. ZAR=; Put BeerinOz=; Run; AUD=$10 ZAR=R95 BeerinOz=$1 Page 6
  • 7. PROC FORMAT; Value $SEX 'M'='Male' 'F'='Female' Other='Unknown'; Quit; CodeN=Male CodeT=Male Score=C Data _null_; CodeN=Put(1, Sex.); CodeT=Put('M', $Sex.); Score=Put('M', $Score.); Put CodeN= CodeT= Score=; Run; SAS PROC FORMAT SAS Data Step Output $FMTNAME Character FMTNAME Numeric PROC FORMAT; Value $SEX 'M'='Male' 'F'='Female' Other='Unknown'; Value SEX 1='Male' 2='Female' Other='Unknown'; Quit; PROC FORMAT; Value $SEX 'M'='Male' 'F'='Female' Other='Unknown'; Value SEX 1='Male' 2='Female' Other='Unknown'; Value $Score 'a'-<'e','A'-<'E'='A' 'e'-<'m','E'-<'M'='B' 'm'-'z~','M'-'Z~'='C'; Quit; Range Page 7
  • 8. PROC FORMAT CNTLIN=Lookup Table Start End <optional> HLO <optional> Type <optional> PROC FORMAT CNTLOUT=Lookup Table Label FmtName Activity_ID Activity Description Fee 1 Letter $8.50 2 Phone - Call $9.00 3 Phone - Receive $5.00 4 Account Open $5.00 5 Account Close $3.00 Data Lookup Start Label FMTNAME 1 $8.50 ACT. 2 $9.00 ACT. 3 $5.00 ACT. 4 $5.00 ACT. 5 $3.00 ACT. Page 8
  • 9. 1 x AccountAccount Activity n x Activities Debt Collection 1. Open Account 2. Call Debtor 3.Send letter to Debtor 4. Debtor calls debtee 5. Close Account Activities Fee n x Fees Fees Stamps Disbursement Admin Legal Postage Page 9
  • 10. Account Activities Activity Fee Accno Activity_ID Date ACC00012345 4 5/01/2014 ACC00012345 1 6/01/2014 ACC00012345 3 10/01/2014 ACC00012345 2 11/01/2014 ACC00012345 5 11/01/2014 ACC00012346 4 5/01/2014 ACC00012346 1 6/01/2014 ACC00012346 3 15/01/2014 ACC00012346 2 15/01/2014 ACC00012346 3 25/01/2014 Fee_ID Fee_asatdate Fee Description Fee_Amount 1 1/01/2014 Admin Fee $3.50 1 1/03/2014 Admin Fee $4 1 1/05/2014 Admin Fee $5.25 2 1/01/2014 Disbursements $1 2 1/04/2014 Disbursements $1.25 3 1/01/2014 Legal Fee $0.50 3 6/04/2014 Legal Fee $1 3 1/06/2014 Legal Fee $0.75 6 1/01/2014 Stamps $1.50 6 5/04/2014 Stamps $1.75 6 1/05/2014 Stamps $2 7 1/01/2014 Postage $2 7 18/05/2014 Postage $2.15 Activity_ID Activity Description Fee_ID 1 Letter 1 1 Letter 2 1 Letter 3 1 Letter 6 1 Letter 7 Activity Fee Account Activities Page 10
  • 11. Format $ACTFEE Activity_ID Activity Description Fee_ID 1 Letter 1 1 Letter 2 1 Letter 3 1 Letter 6 1 Letter 7 2 Phone - Call 1 2 Phone - Call 2 2 Phone - Call 3 2 Phone - Call 9 3 Phone - Receive 1 3 Phone - Receive 2 3 Phone - Receive 3 4 Account Open 4 5 Account Close 5 Lookup Start: Activity_ID- Fee_ID Label A001-001 A001-002 A001-002 A001-003 A001-003 A001-006 A001-006 A001-007 A001-007 Activity-End A002-001 A002-002 A002-002 A002-003 A002-003 A002-009 A002-009 Activity-End A003-001 A003-002 A003-002 A003-003 A003-003 Activity-End A004-004 Activity-End A005-005 Activity-End Cat("A",Put(Activity_ID,Z3.),"-",Put(Fee_ID,z3.)); Page 11
  • 12. Fee_ID Fee_asatdate Fee Description Fee_Amount 1 1/01/2014 Admin Fee $3.50 1 1/03/2014 Admin Fee $4 1 1/05/2014 Admin Fee $5.25 2 1/01/2014 Disbursements $1 2 1/04/2014 Disbursements $1.25 3 1/01/2014 Legal Fee $0.50 3 6/04/2014 Legal Fee $1 3 1/06/2014 Legal Fee $0.75 6 1/01/2014 Stamps $1.50 6 5/04/2014 Stamps $1.75 6 1/05/2014 Stamps $2 7 1/01/2014 Postage $2 7 18/05/2014 Postage $2.15 Format $FEELookup Start: Fee_ID-StartDate End: Fee_ID-EndDate Label 001-0041640 001-0041698 $3.50 001-0041699 001-0041759 $4.00 001-0041760 001-High-Date $5.25 002-0041640 002-0041729 $1.00 002-0041730 002-High-Date $1.25 003-0041640 003-0041734 $0.50 003-0041735 003-0041790 $1.00 003-0041791 003-High-Date $0.75 006-0041640 006-0041733 $1.50 006-0041734 006-0041759 $1.75 006-0041760 006-High-Date $2.00 007-0041640 007-0041776 $2.00 007-0041777 007-High-Date $2.15 Cat(Put(Fee_ID*1, Z3.), "-", Put(Start_Date,Z7.)) Cat(Put(Fee_ID*1, Z3.), "-", Put(End_Date,Z7.)) Fee_ID Start_Date End_Date Fee_Amt 1 2014-01-01 2014-02-28 $4.00 1 2014-03-01 2014-04-30 $5.25 1 2014-05-01 9999-12-31 $5.25 2 2014-01-01 2014-03-31 $1.25 2 2014-04-01 9999-12-31 $1.25 3 2014-01-01 2014-04-05 $1.00 3 2014-04-06 2014-05-31 $0.75 3 2014-06-01 9999-12-31 $0.75 4 2014-01-01 9999-12-31 $5.00 5 2014-01-01 9999-12-31 $3.00 6 2014-01-01 2014-04-04 $1.75 6 2014-04-05 2014-04-30 $2.00 6 2014-05-01 9999-12-31 $2.00 7 2014-01-01 2014-05-17 $2.15 7 2014-05-18 9999-12-31 $2.15 Page 12
  • 13. Account Activities Accno Activity_ID Date Fee Total ACC00012345 4 5/01/2014 $5.00 ACC00012345 1 6/01/2014 $8.50 ACC00012345 3 10/01/2014 $5.00 ACC00012345 2 11/01/2014 $9.00 ACC00012345 5 11/01/2014 $3.00 ACC00012346 4 5/01/2014 $5.00 ACC00012346 1 6/01/2014 $8.50 ACC00012346 3 15/01/2014 $5.00 ACC00012346 2 15/01/2014 $9.00 ACC00012346 3 25/01/2014 $5.00 ACC00012346 1 31/03/2014 $9.00 50c admin fee increase applied on 1/3/2014 Fee_ID Fee_asatdate Fee Description Fee_Amount 1 1/01/2014 Admin Fee $3.50 2 1/01/2014 Disbursements $1 3 1/01/2014 Legal Fee $0.50 6 1/01/2014 Stamps $1.50 7 1/01/2014 Postage $2 Fee_ID Fee_asatdate Fee Description Fee_Amount 1 1/03/2014 Admin Fee $4 2 1/01/2014 Disbursements $1 3 1/01/2014 Legal Fee $0.50 6 1/01/2014 Stamps $1.50 7 1/01/2014 Postage $2 Applicable Fees Accno Activity_ID Date Fee Total ACC00012345 4 5/01/2014 $5.00 ACC00012345 1 6/01/2014 $8.50 ACC00012345 3 10/01/2014 $5.00 ACC00012345 2 11/01/2014 $9.00 ACC00012345 5 11/01/2014 $3.00 ACC00012346 4 5/01/2014 $5.00 ACC00012346 1 6/01/2014 $8.50 ACC00012346 3 15/01/2014 $5.00 ACC00012346 2 15/01/2014 $9.00 ACC00012346 3 25/01/2014 $5.00 ACC00012346 1 31/03/2014 $9.00 Page 13
  • 14. Do Until(Put(Fee_total, $ACTFEE.)='Activity-End'); *** 1. Loop for each activity *** ; Iter+1; If Iter=1 then Fee_total=Put(Cat("A",Put(Activity_ID, z3.)), $ACTFEE.); Else Fee_total=Put(Fee_total, $ACTFEE.); *** 2. Apply correct fee per actiovity for the date *** ; FeePrt=Cat(Strip(Scan(Fee_total,-1,'-')),"-",Put(Asat_Date, z7.)); FeeAmt=Put(FeePrt, $Fee.); Fees=Sum(Fees, FeeAmt); Output;  Add this line if you want to test the breakdown of fees charged End; Account Activities Page 14
  • 15. SAS Formats https://support.sas.com/documentation/cdl/en/leforinforref/64790/HTML/defa ult/viewer.htm#titlepage.htm Sample Code & Test Data <to be determined> Base SAS Procedure guide https://support.sas.com/documentation/cdl/en/proc/66663/HTML/default/vie wer.htm Page 15
  • 16. Email: patrickcuba8@gmail.com Mobile: 0458 91 2634 Linkedin: http://www.linkedin.com/in/patrickcuba Page 16

Editor's Notes

  1. Formats and How to use them by Patrick Cuba @ Cuba BI Consulting
  2. A format is a type of SAS language element that applies a pattern to or executes instructions for a data value to be displayed or written as output. Types of formats correspond to the type of data: numeric, character, date, time, or timestamp. The ability to create user-defined formats is also supported Data _Null_; Text="Hello Bill"; Num=25.50; Date='25FEB2014'd; Time='16:45:24't; DateTime = DHMS(Date, Hour(Time), Minute(Time), Second(Time)); TextMD5=MD5(Text); Put 'Hex' Text=$Hex.; Put 'Upcase' Text=$Upcase.; Put 'Reverse' Text=$Revers20.; Put 'Rounded number' Num=11.; Put 'Two delimiter number' Num=11.2; Put 'Dollar value' Num=DOLLAR10.2; Put 'Normal Date' Date=Date9.; Put 'European standard' Date=yymmdd10.; Put 'Changed delimiter' Date=yymmddp10.; Put 'Date as numeric' Date=11.; Put 'Date as numeric string' Date=Z7.; Put Time=Time8.; Put Datetime=datetime21.2; Put 'MD5' TextMD5=; Put 'Readable MD5' TextMD5=$Hex16.; Run; The MD5 message-digest algorithm is a widely used cryptographic hash function producing a 128-bit (16-byte) hash value, typically expressed in text format as a 32 digit hexadecimal number
  3. Informats are used to import the values in a specified format from files, datalines, datasets or external tables Formats are used to display the underlying data in a SAS format
  4. Using input and puts data can be converted between numeric and character and vice versa
  5. Picture formats give you the ability to create templates for data, much like Excel Text function Currency conversion on the fly!
  6. In addition to the formats that are supplied with Base SAS software, you can create your own formats. In Base SAS software, PROC FORMAT enables you to create your own formats for both character and numeric variables.
  7. Syntax for PROC FORMAT loading a data lookup table into a SAS catalog Start = Lookup value End = Lookup value to range Label = Lookup value returned HLO = High/Low/Other Type = Numeric or character To check formats created use CNTLOUT=
  8. Account has activities Each account attracts activities; Open Account Calling the debtor Sending a letter to the debtor Debtor calling the debtee Multiple letters, calls Finally Account Closure Activity has a fee Each activity attracts a fee 3. Activity has many fees 4. Fees increase over time
  9. Formats are loaded in memory and applied to one activity at a time
  10. Activity Lookup – Build Format table ~~~~~~~~~~~~~~~~~~~~~~ A1 F1 to A1 F2 A1 F2 to A1 F3 A1 F3 to A1 F6 A1 F6 to A1 F7
  11. Fee Lookup – Build Format table with ranges ~~~~~~~~~~~~~~~~~~~~~~~~~~~ F1-1/1/2014 to F1-28/2/2014 – Fee F1-1/3/2014 to F1-30/4/2014 – Fee F1-1/5/2014 to F1-31/12/9999 – Fee
  12. Applies the correct fees over time On 1/3 there was an admin fee increase of 50c That is reflected in the Letter activity on 31/3
  13. Simple loop step to apply fees to an activity and against the time of the activity
  14. 01_Create Reference Tables.sas creates the lookup tables for use in formats 02_Create Data Table.sas create sample data with test cases 03_Create Formats.sas creates formats from the lookup tables 04_Apply Formats.sas applies the formats created to the sample data Account-Activities.csv Activity.csv Fees.csv