Fee Formats v1 no animation
-
Upload
patrick-cuba -
Category
Documents
-
view
121 -
download
3
Transcript of Fee Formats v1 no animation
Formats
Patrick Cuba – Consultant
(SAS® Software)how to use them
and
Page 1
AGENDA
• 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
FORMATS AND INFORMATS
“Hello Bill”THREE CATEGORIES
TEXT $ $20.$UPCASEw.
“HELLO BILL”
$REVERSw
“lliB olleH”
$HEXw. “48656C6C6F2042696C6C”
NUMERIC 11.2611.2 25.50DOLLAR10.2 $25.50
DATE & TIME DATE9. 25FEB2014
yymmdd10. 2014-02-25yymmddp10. 2014.02.25 time8. 16:45:24
datetime21.2 25FEB2014:16:45:24.00
11. 19779
Z7. 0019779
Page 3
INFORMATS
Infile FilenameInput Fee_ID : $10. Asat_Date : YYMMDD10. Desc : $20. Fee_Amt : Dollar.2
1,2014/01/01,Admin Fee,$3.501,2014/03/01,Admin Fee,$4.001,2014/05/01,Admin Fee,$5.25
FORMATS
Format Date yymmdd10. Date=2014-05-16
Date=date(); Date=19859
File textSAS Data step code
DisplaySAS Datastep code
Page 4
CONVERSION
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;
PICTURE FORMATS
AUD=$10 ZAR=R95 BeerinOz=$1
Page 6
USER DEFINED FORMATS
PROC FORMAT; Value $SEX 'M'='Male' 'F'='Female' Other='Unknown';
Quit;CodeN=Male CodeT=MaleScore=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 CharacterFMTNAME 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
USER DEFINED FORMATS
Activity_ID Activity Description Fee1 Letter $8.502 Phone - Call $9.003 Phone - Receive $5.004 Account Open $5.005 Account Close $3.00
Data Lookup
Start Label FMTNAME1 $8.50 ACT.2 $9.00 ACT.3 $5.00 ACT.4 $5.00 ACT.5 $3.00 ACT.
Page 8
BUSINESS CONTEXT
1 x AccountAccount
Activityn 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
BUSINESS CONTEXT
AccountActivities
Activity
Fee
Accno Activity_ID DateACC00012345 4 5/01/2014ACC00012345 1 6/01/2014ACC00012345 3 10/01/2014ACC00012345 2 11/01/2014ACC00012345 5 11/01/2014ACC00012346 4 5/01/2014ACC00012346 1 6/01/2014ACC00012346 3 15/01/2014ACC00012346 2 15/01/2014ACC00012346 3 25/01/2014
Fee_ID Fee_asatdate Fee Description Fee_Amount1 1/01/2014 Admin Fee $3.501 1/03/2014 Admin Fee $41 1/05/2014 Admin Fee $5.252 1/01/2014 Disbursements $12 1/04/2014 Disbursements $1.253 1/01/2014 Legal Fee $0.503 6/04/2014 Legal Fee $13 1/06/2014 Legal Fee $0.756 1/01/2014 Stamps $1.506 5/04/2014 Stamps $1.756 1/05/2014 Stamps $27 1/01/2014 Postage $27 18/05/2014 Postage $2.15
Activity_ID Activity Description
Fee_ID
1 Letter 11 Letter 21 Letter 31 Letter 61 Letter 7
Activity
Fee
AccountActivities
Page 10
ACTIVITY TO FEE RELATIONSHIP
Format $ACTFEE
Activity_ID Activity Description Fee_ID1 Letter 11 Letter 21 Letter 31 Letter 61 Letter 72 Phone - Call 12 Phone - Call 22 Phone - Call 32 Phone - Call 93 Phone - Receive 13 Phone - Receive 23 Phone - Receive 34 Account Open 45 Account Close 5
Lookup
Start: Activity_ID-Fee_ID
Label
A001-001 A001-002A001-002 A001-003A001-003 A001-006A001-006 A001-007A001-007 Activity-EndA002-001 A002-002A002-002 A002-003A002-003 A002-009A002-009 Activity-EndA003-001 A003-002A003-002 A003-003A003-003 Activity-EndA004-004 Activity-EndA005-005 Activity-End
Cat("A",Put(Activity_ID,Z3.),"-",Put(Fee_ID,z3.));
Page 11
BUSINESS CONTEXT
Fee_ID Fee_asatdate Fee Description Fee_Amount1 1/01/2014 Admin Fee $3.501 1/03/2014 Admin Fee $41 1/05/2014 Admin Fee $5.252 1/01/2014 Disbursements $12 1/04/2014 Disbursements $1.253 1/01/2014 Legal Fee $0.503 6/04/2014 Legal Fee $13 1/06/2014 Legal Fee $0.756 1/01/2014 Stamps $1.506 5/04/2014 Stamps $1.756 1/05/2014 Stamps $27 1/01/2014 Postage $27 18/05/2014 Postage $2.15
Format $FEELookup
Start: Fee_ID-StartDate End: Fee_ID-EndDate Label001-0041640 001-0041698 $3.50001-0041699 001-0041759 $4.00001-0041760 001-High-Date $5.25002-0041640 002-0041729 $1.00002-0041730 002-High-Date $1.25003-0041640 003-0041734 $0.50003-0041735 003-0041790 $1.00003-0041791 003-High-Date $0.75006-0041640 006-0041733 $1.50006-0041734 006-0041759 $1.75006-0041760 006-High-Date $2.00007-0041640 007-0041776 $2.00007-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_Amt1 2014-01-01 2014-02-28 $4.001 2014-03-01 2014-04-30 $5.251 2014-05-01 9999-12-31 $5.252 2014-01-01 2014-03-31 $1.252 2014-04-01 9999-12-31 $1.253 2014-01-01 2014-04-05 $1.003 2014-04-06 2014-05-31 $0.753 2014-06-01 9999-12-31 $0.754 2014-01-01 9999-12-31 $5.005 2014-01-01 9999-12-31 $3.006 2014-01-01 2014-04-04 $1.756 2014-04-05 2014-04-30 $2.006 2014-05-01 9999-12-31 $2.007 2014-01-01 2014-05-17 $2.157 2014-05-18 9999-12-31 $2.15
Page 12
BUSINESS CONTEXT
AccountActivities
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_Amount1 1/01/2014 Admin Fee $3.502 1/01/2014 Disbursements $13 1/01/2014 Legal Fee $0.506 1/01/2014 Stamps $1.507 1/01/2014 Postage $2
Fee_ID Fee_asatdate Fee Description Fee_Amount1 1/03/2014 Admin Fee $42 1/01/2014 Disbursements $13 1/01/2014 Legal Fee $0.506 1/01/2014 Stamps $1.507 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 chargedEnd;
BUSINESS CONTEXT
AccountActivities
Page 14
REFERENCES
SAS Formatshttps://support.sas.com/documentation/cdl/en/leforinforref/64790/HTML/default/viewer.htm#titlepage.htm
Sample Code & Test Data<to be determined>
Base SAS Procedure guidehttps://support.sas.com/documentation/cdl/en/proc/66663/HTML/default/viewer.htm
Page 15
QUESTIONS
Patrick CubaEmail: [email protected]: 0458 91 2634Linkedin: http://www.linkedin.com/in/patrickcuba
Page 16