Published on :
ETL CREATION_INTERNE

Data Formatting and Payroll Calculation

This code is also available in: Deutsch Español Français
Awaiting validation
This program creates a SAS© table named 'PAY' from raw data included in the code. It demonstrates the use of multiple INPUT statements to read observations spread across multiple lines (identifiers on the first, hours on the second). It then performs arithmetic calculations to determine paychecks and applies specific formats (SSN for social security identifiers, Dollar for rates).
Data Analysis

Type : CREATION_INTERNE


Data is generated by the DATALINES statement within the Data Step.

1 Code Block
DATA STEP Data
Explanation :
Creation of the PAY table. The script reads the ID, last name, first name, and hourly rate on one line, then the hours worked (hour1 to hour3) on the next line. It calculates three paycheck amounts and formats the ID with the social security format (ssn11.) and the rate in currency (dollar6.2).
Copied!
1/* Topic 11 data formating */
2 
3DATA PAY;
4INPUT id lastname $ firstname $ payrate;
5INPUT hour1 - hour3;
6paycheck1 = payrate*hour1;
7paycheck2 = payrate*hour2;
8paycheck3 = payrate*hour3;
9FORMAT id ssn11.
10 payrate dollar6.2;
11DATALINES;
12528013351 Jones Emily 15.85
1338 40 37
14205284178 Smith Jeremy 13.45
1544 38 42
16271044878 Mitchell Tyler 15.65
1739 38 45
18;
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.