This script executes a DATA step to create the PAY table. It reads raw data spread over multiple lines for each observation (identifier, last name, first name, hourly rate, hours worked, and start date). It also calculates a derived variable 'x' corresponding to the year of the start date.
Data Analysis
Type : CREATION_INTERNE
The data is integrated directly into the script using the DATALINES statement.
1 Code Block
DATA STEP Data
Explanation : DATA step defining the PAY table. The INPUT statement uses a line break indicator '/' to read variables 'hour1' to 'hour3' and 'startdate' on subsequent lines. The YEAR function extracts the year from the start date.
Copied!
Data PAY;
input id lastname $ firstname $
payrate / hour1-hour3/
startdate MMDDYY10.;
x = year(startdate);
format startdate MMDDYY10.;
Datalines;
528013351 Jones Emily 15.85
30 40 37
1/13/2012
205284178 Smith Jeremy 13.45
44 38 42
1/13/2012
271044878 Mitchell Tyler 15.65
39 38 45
1/13/2012
;
1
DATA PAY;
2
INPUT id lastname $ firstname $
3
payrate / hour1-hour3/
4
startdate MMDDYY10.;
5
x = year(startdate);
6
FORMAT startdate MMDDYY10.;
7
DATALINES;
8
528013351 Jones Emily 15.85
9
304037
10
1/13/2012
11
205284178 Smith Jeremy 13.45
12
443842
13
1/13/2012
14
271044878 Mitchell Tyler 15.65
15
393845
16
1/13/2012
17
;
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.