The script consists of three main blocks. The first block calculates the duration (days, business days, weeks, months) between the current date and a predefined holiday date, storing the results in a CAS table. The second block generates fictitious payment information, including a customer ID, a due date, and a payment receipt date, then saves them to another CAS table. The third block uses PROC PRINT to display records of customers whose payment was received more than 10 business days after the due date.
Data Analysis
Type : CREATION_INTERNE
All data processed and generated by this script is created internally. The first table is built from internal SAS functions (TODAY()) and literal dates. The second table is randomly generated using the RAND() function. No external data or SASHELP library is used as a primary source.
1 Code Block
DATA STEP Data
Explanation : This DATA STEP block initializes a CAS session and creates the 'casuser.tidTillSemestern' table. It calculates the difference between the current date (IDAG) and a semester start date (STARTSEM) using the INTCK function. Calculations are performed in days (DAGARTILLSEM), business days (VECKODAGARTILLSEM), weeks (VECKORTILLSEM), and months (MANADERTILLSEM), with the 'c' option for continuous counting for weeks and months. Dates are formatted as DDMMYYYY.
Copied!
cas;
data casuser.tidTillSemestern;
idag = today();
startSem = '15jun2023'd;
dagarTillSem = intck('day', idag, startSem);
veckodagarTillSem = intck('weekday', idag, startSem);
veckorTillSem = intck('week', idag, startSem, 'c');
manaderTillSem = intck('month', idag, startSem, 'c');
format idag startSem yymmdd10.;
run;
Explanation : This DATA STEP block creates the 'casuser.betalningsInformation' table by generating 20 fictitious data records. For each 'kundID' (customer ID), it assigns a random 'forfallodatum' (due date) in March 2023 and a 'betalningInkommen' (payment receipt date) which is the due date plus or minus a random number of days (between -5 and 20). Dates are also formatted as DDMMYYYY.
Copied!
/*skapa data*/
data casuser.betalningsInformation;
do kundID = 1 to 20;
forfallodatum = rand('integer', '01mar2023'd, '31mar2023'd);
betalningInkommen = forfallodatum + rand('integer', -5, 20);
output;
end;
format forfallodatum betalningInkommen yymmdd10.;
run;
Explanation : This block uses PROC PRINT to display a selection of records from the 'casuser.betalningsInformation' table. The WHERE clause filters records to include only customers whose difference between the due date and the payment receipt date, calculated in business days ('weekday') by the INTCK function, is greater than 10. This identifies customers with significant payment delays. The ID statement specifies that the KUNDID variable should be used as an identifier in the report.
Copied!
/*Kunder som är mer än 10 veckodagar sena med sin betalning*/
proc print data=casuser.betalningsInformation;
id kundID;
where intck('weekday', forfallodatum, betalningInkommen) > 10;
run;
1
/*Kunder som är mer än 10 veckodagar sena med sin betalning*/
2
PROC PRINTDATA=casuser.betalningsInformation;
3
id kundID;
4
where intck('weekday', forfallodatum, betalningInkommen) > 10;
5
RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.